I am having some trouble with the following stuff. I am creating a string of characters that are going to be passed as a buffer into a Unix Pipe. I decided to use Ostream to do this. I have to create the following strings and pass them into the Unix Pipe one by one. The strings I have to create are as follows: "1a", "2aa", "3aaa"..."10aaaaaaaaaa", "11a", "12aa", "13aaa" ... "20aaaaaaaaaa" ......."291a", "292aa", "293aaa", "294aaaa", "299aaaaaaaaa", "300aaaaaaaaaa".
here is my code segment. I have the correct headers declared. my problem with this though is that my str consists of all the old oss stuff. basically it remebers all the 1a 2aa, etc all the way up to 300aaaaaaaaa. Is there a way to flush the oss stream so that only one string is produced at a time so that it does not remember my previous streams? I tried the flush command but I dont think that is correct. Aslo...if you have any better suggestions on how to do this I would apprecaite it the offer,
. Thanks.
int a = 1;
int i = 1;
int j = 1;
ostringstream oss;
while (i <= 300) {
oss << i;
while (j <= a) {
oss << 'a';
j++;
}
string str = oss.str();
//need to clear the oss here I think.
cout << str << '\n';
i++;
a++;
if (a == 11) {
a = 1;
}
j = 1;
}
here is my code segment. I have the correct headers declared. my problem with this though is that my str consists of all the old oss stuff. basically it remebers all the 1a 2aa, etc all the way up to 300aaaaaaaaa. Is there a way to flush the oss stream so that only one string is produced at a time so that it does not remember my previous streams? I tried the flush command but I dont think that is correct. Aslo...if you have any better suggestions on how to do this I would apprecaite it the offer,
int a = 1;
int i = 1;
int j = 1;
ostringstream oss;
while (i <= 300) {
oss << i;
while (j <= a) {
oss << 'a';
j++;
}
string str = oss.str();
//need to clear the oss here I think.
cout << str << '\n';
i++;
a++;
if (a == 11) {
a = 1;
}
j = 1;
}