開發平台(Platform): (Ex: Win10, Linux, ...)
win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
visual studio 2015
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
想請問是不是vector使用上哪裡出了問題導致非預期的結果,謝謝!!!!!
預期的正確結果(Expected Output):
0
1
錯誤結果(Wrong Output):
1
1
程式碼(Code):(請善用置底文網頁, 記得排版)
vector<WCHAR*> pList;
for (int ndx = 0; ndx < 2; ndx++)
{
string name = to_string(ndx);
int len2 = strlen(name .c_str()) + 1;
char outch2[MAX_PATH];
WCHAR * wChar2 = new WCHAR[len2];
wChar2[0] = 0;
MultiByteToWideChar(CP_UTF8, 0, name .c_str(), len2, wChar2, len2);
WideCharToMultiByte(CP_ACP, 0, wChar2, len2, outch2, len2, 0, 0);
delete[] wChar2;
char* pchar2 = (char*)outch2;
len2 = strlen(pchar2) + 1;
WCHAR outName2[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, pchar2, len2, outName2, len2);
pList.push_back(outName2);
}
for (int ndx = 0; ndx < pList.size(); ndx++)
{
printf("%S\n", pList[ndx]);
}
補充說明(Supplement):