I have a simple question but any one makes me known. below there is simple code.
#include <iostream>
#include <string>
using namespace std;
int main(){
string ans;
while(true){
cin >> ans;
cout << "ans : " << ans << endl;
}
}
I type usa canada england island
and enter !!
It shows result below
usa canada england island
ans : usa
ans : canada
ans : england
ans : island
hello world
ans : hello
ans : world
Why does it skip second cin
??
How does it work in stream buffer?
Please answer my question thank you