[gameprogrammer] How to assign a numeric variable to an std::string?

float f=5;
std::string myStr;
myStr << f;

It doesn't work.

Error 1 error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::string'

So how do I do this?  E.G.
sprintf(str, "%f", f);

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: