W
wang
Hi all,
I tried to format several numbers into strings using an ostringstream
in the following way:
ostringstream oss;
double x = 1.2, y = 5.3;
string xs, ys;
oss << x;
xs = oss.str();
oss << y;
ys = oss.str();
But ys has the result "1.25.3". Obviously y is appended to x. oss must
be "cleared" before y is formatted. But how? I inserted "oss.str("");"
before "oss << y;", the result is the same -- the empty string is
appended to oss again. Thanks for any help!
kwwang
I tried to format several numbers into strings using an ostringstream
in the following way:
ostringstream oss;
double x = 1.2, y = 5.3;
string xs, ys;
oss << x;
xs = oss.str();
oss << y;
ys = oss.str();
But ys has the result "1.25.3". Obviously y is appended to x. oss must
be "cleared" before y is formatted. But how? I inserted "oss.str("");"
before "oss << y;", the result is the same -- the empty string is
appended to oss again. Thanks for any help!
kwwang