Hi,
When I copy paste a text in the command prompt for one of the "cin" the text will gets in the other too and loops 3 or 4 times.
Its a text without space so it shouldn't get fragmented.
I tried to use cin.ignore(); and fflush(stdin); but it won't change a thing.
What's happening here?
Edit: apparently its the new line that causes it but wouldn't cin.ignore(); and fflush(stdin); should empty what's in "cin" ?
Code:#include <string> #include <iostream> using namespace std; int main() { string response; char buf[1255]; while(1) { cin >> response; cout << "string: "<<response << endl; cin >> buf; cout << "buf: "<< buf << endl; } return 0; }