Jump to content
  • Advertisement
Sign in to follow this  
leonlylin

how to change float to wchar?

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

Advertisement
You could use the wsprintf function with which you can format strings and include stuff. Possibily you could also use a function like ftoa

Share this post


Link to post
Share on other sites
Quote:
Original post by leonlylin
i use direct3d(API) and the OS is winxp.i want to change the float to wchar for display.but i did not find the funtion.


There's a couple of ways; the simplest is probably to do something like this:


WCHAR Buffer[256];
swprintf(Buffer, "%f", MyFloat);



Another path would be std:wstream; it depends on what you prefere.

Allan

Share this post


Link to post
Share on other sites
A more generic way would be

#include <sstream>

template<typename T>
std::string to_string( T const & value ) {
std::stringstream ss;
ss << value;
return ss.str();
}

template<typename T>
std::wstring to_wstring( T const & value ) {
std::wstringstream ss;
ss << value;
return ss.str();
}

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!