what is LPCTSTR
LPCTSTR is a windows typedef. It stands for Long Pointer to a Constant T String. A T string is a null terminated array that is of WCHARs when UNICODE is defined and CHARs when UNICODE is not defined.
Ok well Ithough this should work but I will ask first and see if I did this right.
How can I use ifstream to load a file to LPCTSTR?
I am alos using dev c++ so I have no idea if I am using unicode or not.
How can I use ifstream to load a file to LPCTSTR?
I am alos using dev c++ so I have no idea if I am using unicode or not.
You probably aren't. Here's a way to check: do a sizeof(TCHAR) somewhere in your program and see what it spits out. If the result is 1 then you probably don't have UNICODE defined.
I did get a 1. How do I define it?
I got that fixed but I dont think it will fix my problem.
I need to load LPCTSTR lpName from ifstream fin(filename);
Do I make filename a char, a string or what ?
[Edited by - kingpinzs on November 11, 2005 11:11:12 PM]
I got that fixed but I dont think it will fix my problem.
I need to load LPCTSTR lpName from ifstream fin(filename);
Do I make filename a char, a string or what ?
[Edited by - kingpinzs on November 11, 2005 11:11:12 PM]
Before you include a Windows-related headers, #define UNICODE.
Of course, the question is whether you want to define UNICODE: are your text assets in UNICODE, MBCS or ASCII?
As for loading data into an LPCTSTR using std::ifstream, if you're not using UNICODE then it's the same as loading into a char * buffer and passing that buffer to the function with LPCTSTR parameter. Alternately - and, frankly, better - load the data into a std::string and pass the return value of std::string::c_str() to the legacy (probably Win32 API) function that needs an LPCTSTR.
Of course, the question is whether you want to define UNICODE: are your text assets in UNICODE, MBCS or ASCII?
As for loading data into an LPCTSTR using std::ifstream, if you're not using UNICODE then it's the same as loading into a char * buffer and passing that buffer to the function with LPCTSTR parameter. Alternately - and, frankly, better - load the data into a std::string and pass the return value of std::string::c_str() to the legacy (probably Win32 API) function that needs an LPCTSTR.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement