as the compiler is telling you, the first argument of fstream::open can only be const char* or std::string, while you're trying to give it a const wchar_t* for some reason... probably because you have a program that was written for Visual Studio and used its non-portable extensions (specifically, this one: https://msdn.microsoft.com/library/8473817e-42a4-430b-82b8-b476c86bcf8a.aspx#basic_fstream__open )
@gunnerfunner : nothing special in the code , i just have a unicode file name , then i want to open it with fstram , that's all :) .
--------------------------------
--------------------------------
@Cubbi :
i have files with unicod string name , there is any solution to open such those files .
beside , if i turn to VC++ this code will works fine ?
thanks ,
--------------------------------
--------------------------------
@Thomas1965 : as you can see in the title , acctually i am using wfstream , always the same probleme .
Also the following code do not work !!! : f.open(L"myfile.txt", ios::in | ios::out | ios::binary);
or, even more succinctly: std::ifstream inFile{"F:\\test.txt"};
ps: please don't edit OP and put code in there, it disturbs the flow of the thread and keeps future readers wondering. it's better to make a separate post continuing the thread. thanks
i have files with unicod string name , there is any solution to open such those files. beside , if i turn to VC++ this code will works fine ?
You seem to have a string with UTF-16-encoded file name (if you're lucky). It is just one of many ways to store a Unicode string.
Where are you going to run this program on?
If it's not Windows, convert it to UTF-8 and pass that to fstream's constructor/open as std::string. If it's Windows, use Visual Studio or find some other way to get that file name that doesn't go through Windows's unusable wide string - where did it come from in your program in the first place?
In general, if you want it to be portable between Windows and Linux/MacOS, wait for C++17 or use boost.filesystem.
@Thomas1965 wifstream's constructor/open also expects string/char*/filesystem::path, not wstring/wchar_t
this declaration maybe workinfg fo c++11 .
I have unicode file name , the name of the file is not myFile.txt , it is in unicode string . i want to open that file .