Sign in to follow this  

how to change float to wchar?

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

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

This topic is 4381 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this