Help with std::string

Started by
3 comments, last by BettaThnU 19 years, 4 months ago
Hey guys I was wondering if any of you knew how to change a std::string to an LPCSTR. All of my string data is stored as a std::string but the function I need to use will only work with and LPCSTR. Any help would be greatly appreciated. BTW The function Iam trying to use is the ID3DXFont::DrawText.
Advertisement
Do you know what an LPCTSTR is a typedef for? const char *. Do you know what member of std::string returns a const char *? c_str.
std::string aString;void SomeFunction(LPCTSTR param);...SomeFunction(aString.c_str());

Happy hacking!
Use the .c_str() member:
std::string str;LPCSTR lps = str.c_str();


regards,
Pat.

[edit]
Too slow...[smile]
[/edit]
string str = "This is a string";LPCSTR cstr = str.c_str();

Basically, the c_str() method of the string class return a const char *, and an LPCSTR is the same thing (long pointer to a constant string).

Regards,
jflanglois

[edit] Hmph, beaten
All you guys rock, and for the record you all get gold no matter who posted first. Thanks all

This topic is closed to new replies.

Advertisement