I am using cin to input a single character from keyboard.The problem is that if 2 or more characters are entered then the rest of the characters are being considered as input for the further cin statements.Is there any way in which I can clear the inpu buffer memory after every cin statement so that rest of the characters are removed from the buffer.
Eg.
char ch;
cout<<"\nInput a character:";
cin>>ch;
cout<<"\nInput another character:";
cin>>ch;
In the above example if two characters are entered at the first instance then the second character is considered as the input for the second cin statement.
I have tried using flush(), eof() and ignore() to no effect.
How to avoid this?Any help is highly appreciated.