[Screenshot 1] The screen is not stopping on cin.get() functions for the user to input something. Maybe automatically taking the "enter key" from the buffer.
[Screenshot 2] On using some functions to clear the buffer (like cin.ignore() and fflush(stdin) ), everything is working as required.
My questions are:
(If I am getting something wrong, please point out)
-Why does cin.get() automatically taking the "enter key" from the buffer (previous inputs)?
- Why do simple implementations of cins not follow this thing?
Like:
-Are these functions (of clearing buffers) especially designed for such cases? Could you provide an example scenario where we don't need those functions? I mean why would someone want to access the previous buffer data of "enter key".
[Screenshot 2] On using some functions to clear the buffer (like cin.ignore() and fflush(stdin) ), everything is working as required.
My questions are:
(If I am getting something wrong, please point out)
-Why does cin.get() automatically taking the "enter key" from the buffer (previous inputs)?
- Why do simple implementations of cins not follow this thing?
Like:
Code:
cout<<"enter something"; cin>>a; cout<<"enter something"; cin>>b; cout<<"enter something"; cin>>c; // Here the screen stops everytime
Comment