[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 740
  • Last Modified:

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.
0
cophi
Asked:
cophi
  • 3
1 Solution
 
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:
If your project is Unicode, you can use wifstream instead of ifstream.
0
 
AlexFMCommented:
   CString s;
    ifstream in(s);

    CString s;
    wifstream in(s);

Both versions are compiled in my VC++ 8.0.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now