Your question is a bit vague, but the sample code makes it more clear.
You have two options:
Initialize ostringstream first through the construct (build another instance at each step of the loop):
for(int i = 0; i < 10; ++i) { value = rand() % 100 ; ostringstream os; os << value; cout << os.str() << " " << os << endl; ntree->insert(os.str());
Secondly, reset the internal buffer and clear the stream state (error state, eof flag, etc.):
for(int i = 0; i < 10; ++i) { value = rand() % 100 ; os << value; cout << os.str() << " " << os << endl; ntree->insert(os.str());
utnapistim
source share