0

I use eclipse with minGW 32. I created a class:

Data(HWND hwnd,  wchar_t szFileName[MAX_PATH])
{
std::vector<std::string> fileRows;  
    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);
    }
}

but the ifstream in MinGW could not resolve the wchar_t. How can I store the file lines int the fileRows vector? Absolutely sure that the file lines are string not wstring. So I should store the lines in a std::vector<std::string>

Carl Mark
  • 371
  • 1
  • 12
  • 23
  • I would avoid unicode filenames where possible. Meanwhile, read this: http://stackoverflow.com/questions/402283/stdwstring-vs-stdstring – paddy Apr 02 '13 at 01:04

1 Answers1

1

If you intend to read text data using wchar_t, use std::wifstream to read it and std::wstring to store it.

std::ifstream and std::string are designed specifically to use char.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180