I have been trying a similar string manipulation code below, but I have been getting an error with my instantiation of flist with the error
Code:
1>e:\test\installer\installer.cpp(105) : error C2057: expected constant expression
1>e:\test\installer\installer.cpp(105) : error C2466: cannot allocate an array of constant size 0
1>e:\test\installer\installer.cpp(105) : error C2075: 'flist' : array initialization needs curly braces
Code:
int flist_num = argc - INSTARGC;
if (flist_num > 0)
{
wstring flist[flist_num] = 0;
for (DWORD i = 0; i < flist_num; i++)
{
size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, argv[i+INSTARGC], -1, 0, 0);
if(size==0)
{
wcout << "Error occurred when trying to allocate memory for conversion"
<< endl;
}
tempPrinterName = new WCHAR[size];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, argv[i+INSTARGC],
-1, tempPrinterName, size);
flist[i] = wstring(tempPrinterName);
delete[] tempPrinterName;
wcout << flist[i] << endl;
}
}
My trouble is that I don't really know what would be in the contents of flist until I have finished processing the arguments passed in the main function. Would I need to have some type of variable arrays to do this?