Jump to content
  • Advertisement
Sign in to follow this  
Q-Parser

CString to char*

This topic is 4778 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

Hi, sorry for that lame question, but is there any way how to convert CString to char* in VC++, except for copying characters from one string to another. Thanks

Share this post


Link to post
Share on other sites
Advertisement
CString has a direct cast operator to "const char*" which should be enough for most uses. Note that you MUST not modify the data pointed to by CString.

Example:

CString cstrGnu( "20" );

int iValue = atoi( cstrGnu );


This would call the cast operator implicitely, you can also do so explicit:

wsprintf( szGnu, "Hello %s", (LPCTSTR)cstrGnu );

LPCTSTR is a define which maps to either const char* or const wchar_t* (depending on your projects unicode setting).

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!