In article <MP************************@news.westnet.com.au> ,
Woodster <mi****@127.0.0.1> wrote:
In article <3F***************@adcc.alcatel.be>,
Sa********************@adcc.alcatel.be says... Use stringstream
#include <iostream>
#include <sstream>
int main()
{
std:: stringstream str;
double value = 10.5;
str<<"text "<<value<<" text";
string buffer(str.str());
Only problem is that this does not allow formatting of the variable (ie:
%.2f in this case). Is there a way I can still format the variable
'value'
Sure, use stream manipulators just like you would if you were writing to
cout or a file. I'm not completely "up" on C-style formatting so I'm not
sure exactly what format you want, but this might come close:
str << "text " << fixed << setprecision(2) << value << " text";
--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA