In this slice of code I get an output of
bbb 55 66 77 88
aaa
the output I expect and want is
bbb 55 66 77 88
bbb
because I reassign ss
from log[0]
to log[1]
.
So my question is why is the output different from what I expect and how do I
change it to what I want?
int w,x,y,z;
stringstream ss (stringstream::in | stringstream::out);
string word;
string log[2];
log[0]="aaa 11 22 33 44";
log[1]="bbb 55 66 77 88";
ss<<log[0];
ss>>word;
int k=0;
ss>>w>>x>>y>>z;
k++;
ss<<log[k];
cout<<log[k]<<endl;
ss>>word;
cout<<word<<endl;
return 0;