Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualThe King2

Posted 18 March 2013 - 12:45 PM

Hello,

 

I want to write a function that converts a float value to a LPCWSTR, like this:

 

    LPCWSTR ToString(float value) {
        wstringstream stream;
        wstring string;
        stream << value;
        stream >> string;
        return string.c_str();
    }

But, as you can see in the attached file, it only outputs weird letters. The debugger tells me that this is really the content of the stream after I "<<" the float value. It does not depend on the exact value oft he float, and it also happens when I try to insert a normal string, or int. Any ideas why this could be failing? Both sstream and string are included, and as far as my old work with the string streams and the dozens of internet examples go, I'm doing everything right, despite that bug...


#1The King2

Posted 18 March 2013 - 12:45 PM

Hello,

 

I want to write a function that converts a float value to a LPCWSTR, like this:

 

    LPCWSTR ToString(float value) {
        wstringstream stream;
        wstring string;
        stream << value;
        stream >> string;
        return string.c_str();
    }

But, as you can see in the attached file, it only outputs weird letters. The debugger tells me that this is really the content of the stream after I "<<" the float value. It does not depend on the exact value oft he float, and it also happens when I try to insert a normal string, or int. Any ideas why this could be failing? Both sstream and string are included, and as far as my old work with the string streams and the dozens of internet examples go, I'm doing everything right, despite that bug...


PARTNERS