Jump to content
  • Advertisement
Sign in to follow this  
Luonnos

Error with CString.Format()

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

I'm using Visual C++ 2008 Standard in an MFC program. When I try to compile the following piece of code, it gives me an error: CString str; double d=3.1415; str.Format("%f",d); AfxMessageBox(str); On the third line, it says: error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' What do I do to convert a double to a CString? It seems like this should work. Can anyone figure out how to stop this error?

Share this post


Link to post
Share on other sites
Advertisement
You're compiling in unicode but have specified an ansi format string. Either prefix the format with 'L' or set the compiler to ANSI (preferred).

Jans.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!