convert std::string to LPTSTR

  • Thread starter Thread starter Abhishek
  • Start date Start date
how to do convert a std::string to LPTSTR (chat *) datatype

There is no way to do that, what you can do (and possibly what you
need) is this:

std::string s;
....
LPCSTR pS = s.c_str()

Dave
 
Abhishek said:
how to do convert a std::string to LPTSTR (chat *) datatype

regards
Abhishek

Abhishek:

Modern windows programming is best done using a Unicode build, for which
LPTSTR is a wide character string. Also, to convert a std::string to a
C-style string without copying you can only obtain a constant string
(LPCTSTR).

Perhaps you really want something like the following

typedef std::basic_string<TCHAR> tstring;
tstring str = _T("Hello world");
LPCTSTR buf = str.c_str();
 
Back
Top