[gameprogrammer] Re: How to assign a numeric variable to an std::string?
- From: "Alan Wolfe" <alan.wolfe@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Fri, 11 Jan 2008 13:43:47 -0800
I am a fan of sprintf and char * arrays as well so am not certain, but
i believe what you are looking for is string.format (:
On 1/11/08, Kevin Jenkins <gameprogrammer@xxxxxxxxxx> wrote:
> 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
>
>
>
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] How to assign a numeric variable to an std::string?
- From: Kevin Jenkins
Other related posts:
- » [gameprogrammer] How to assign a numeric variable to an std::string?
- » [gameprogrammer] Re: How to assign a numeric variable to an std::string?
- » [gameprogrammer] Re: How to assign a numeric variable to an std::string?
- » [gameprogrammer] Re: How to assign a numeric variable to an std::string?
- » [gameprogrammer] Re: How to assign a numeric variable to an std::string?
- » [gameprogrammer] Re: How to assign a numeric variable to an std::string?
- » [gameprogrammer] Re: How to assign a numeric variable to an std::string?
- » [gameprogrammer] Re: How to assign a numeric variable to an std::string?
- [gameprogrammer] How to assign a numeric variable to an std::string?
- From: Kevin Jenkins