I'm trying to read a block of data end with "()" from the user and send it to stringstream, doing some operations on it (for ease now let's said I just want to print these data), and accept a new block of data again, finished this by enter EOF, Here is the code
while(cin >> temp)
{
if(temp != "()")
{
strem << temp + " ";
}
else
{
while(strem >> str)
cout << str << " ";
cout << "\n";
strem.str("");
}
}
Now after this line strem.str("");
strem didn't read any data in the next loop. I try to debug this by adding this line
cout << strem.str() << "\n";
so the whole code is
while(cin >> temp)
{
if(temp != "()")
{
strem << temp + " ";
cout << " strem.str() : " cout << strem.str() << "\n";
}
else
{
while(strem >> str)
cout << str << " ";
cout << "\n";
//strem.str("");
strem.str(string());
}
}
to see what is the content of the strem, to summarize, it's print the first block, but after that print nothing. any idea what's going on!!