【C++代码】 void DefinitionDialog::Init(void) { ifstream file(manager->fileName); string str; char ch; int i = 0; char search[MAX_LOADSTRING_SHORT]; char keyword[MAX_LOADSTRING_SHORT]; sprintf_s(search, "this[%d]", monsterId); while (ch = file.get(), !file.eof()) { switch (ch) { case '\t': continue; case ' ': case '.': case '\r': case '\n': case '=': i = 0; if (strcmp(keyword, search) == 0) { sprintf_s(keyword, "RXData.Monsters[%d]", monsterId); str += keyword; str += ch; while (ch = file.get(), ch != '\n') str += ch; str += "\r\n"; } memset(keyword, 0, MAX_LOADSTRING_SHORT); continue; } if (i < MAX_LOADSTRING_SHORT - 1) keyword[i++] = ch; } file.close();
if (!str.empty()) { // 删除末尾的换行符 str.pop_back(); str.pop_back(); } wstring wstr = toWideStr(str); SetDlgItemText(hDlg, IDC_EDIT1, wstr.data()); }
|