CString for ifstream

I have a cstring which contains the path to the file I want to use.

So fill in the blank what I should put here.

ifstream in(BLANK);

I've tried GetBuffer and it complained.  I tried casting to LPCTSTR and it complained.
cophiAsked:
Who is Participating?
 
AlexFMCommented:
If your project is Unicode, you can use wifstream instead of ifstream.
0
 
AlexFMCommented:
How exactly does it complain?
0
 
cophiAuthor Commented:
error C2440: 'initializing' : cannot convert from 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::PCXSTR' to 'const char *'
        with
        [
            BaseType=wchar_t,
            t_bMFCDLL=true
        ]
0
 
AlexFMCommented:
   CString s;
    ifstream in(s);

    CString s;
    wifstream in(s);

Both versions are compiled in my VC++ 8.0.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.