[try Beta version]
Not logged in

 
Open file

Oct 5, 2011 at 5:15pm
Hello, I have problem with opening of file choosed via OpenFile Dialog box.
Now I wanna open this file for reading/writing, but comilator showes me this error:
error C2664: '_wfopen_s' : cannot convert parameter 3 from 'const char [3]' to 'const wchar_t *'

I'm using this for opening of my file:
_wfopen_s(&file, ofn.lpstrFile, "w+");

How can I solve this ?
Oct 5, 2011 at 6:27pm
_wfopen_s(&file, ofn.lpstrFile, L"w+");
Oct 5, 2011 at 6:28pm
You need to learn about wide character verses ansi strings, and take care to use the correct versions of the functions for whichever setup you are using. If you are setup for ansi builds, don't try to open the file using wide character functions. In the case above the "w" is an ansi character and the function requires a wide character parameter, i.e.,

L"w+", or _T("w+") if using the tchar.h macros.
Oct 5, 2011 at 6:32pm
Oh thank's a lot, problem solved
Topic archived. No new replies allowed.