M
Mark Warren
Ericcson said:Hi.
----------------------------------------
#include <fstream>
#include <stdlib.h>
#include <sstream>
#include <iostream>
using namespace std ;
int main() {
ostringstream myO;
myO << 12;
cout << "myO = " << myO.str() <<endl;
myO << 8;
cout << "myO =" << myO.str() <<endl;
return 0;
}
--------------
I get :
12
128
I would like to get :
12
8
i.e to clear the myO buffer before filling it with "8".
I don't find how. Could someone help me ?
TIA
Ericsson
PS : the all strory is that I try to convert an integer to a string . I
tried itoa(12,s,10) and sprintf(s,"%d",12) with or without c_str() and only
got compilation errors.
Use myO.str(""). A non-obvious use and IMHO poor design, a function should
only have one use.
Mark