Reputation: 371
I use mingw compiler.
How to convert wchar_t
to char
?
Data(HWND hwnd, wchar_t szFileName[MAX_PATH])
{
string sIn;
ifstream infile;
infile.open(szFileName);
infile.seekg(0,ios::beg);
// fill vector with file rows
while ( getline(infile,sIn ) )
{
fileRows.push_back(sIn);
}
}
I would like to convert wchar_t szFileName to char szFileNameChar.
Upvotes: 0
Views: 8251
Reputation: 6682
string str("i'm char[]");
wstring wstr(str.begin(), str.end());
wstring wstr(L"i'm wchar_t[]");
string str(wstr.begin(), wstr.end());
To see a detailed explanation, please refer to the following post: std::wstring VS std::string
Upvotes: 5