A
Alexander Malkis
How to recover from failing cin.get(str,n,'\n')?
The user pressed "Enter" on cin.get(...).I would like to let him try
once more but the system doesn't stop on the next cin.get. Code:
cin.get(str,n,'\n');
cout<<"haha\n";
char c;
/*
Now get '\n'. Doesn't work if the first time nothing else was input.
Have this line or leave it -it doesn't change the outcome in this case.
*/
cin.get(c);
cin.get(str,n,'\n'); //here doesn't wait if the first time Enter was
pressed.
The user pressed "Enter" on cin.get(...).I would like to let him try
once more but the system doesn't stop on the next cin.get. Code:
cin.get(str,n,'\n');
cout<<"haha\n";
char c;
/*
Now get '\n'. Doesn't work if the first time nothing else was input.
Have this line or leave it -it doesn't change the outcome in this case.
*/
cin.get(c);
cin.get(str,n,'\n'); //here doesn't wait if the first time Enter was
pressed.