|
-
February 10th, 2009, 04:17 PM
#1
Clearing I/O stream
Ok, I've been searching google for about 30 minutes and can't find the answer to this question. I suspect it's trivial, but I don't know.
The problem is I want to build a string out of a combination of characters and integers.
I have:
Code:
ostringstream sout;
basic_string<char> exotic_name;
vector< basic_string<char> > file_names;
int exotic_num;
int i, j;
for( i = 1; i <= exotic_num; i++ )
{
for( j = 1; j <= exotic_num; j++ )
{
sout.clear();
sout << exotic_name << i << '_' << "bar" << exotic_name << j;
file_names.push_back( sout.str() );
}
}
Ok, so the problem is this: when I run the code, the sout.clear() line doesn't seem to do anything. That is, the last entry in the vector file_names contains ALL of the data in the loop. I want to clear the output from sout after each loop iteration, but have no idea about how to do this.
Help is appreciated greatly!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|