Jump to content
  • Advertisement
Sign in to follow this  
BettaThnU

Help with std::string

This topic is 4971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!