cin.ignore
is a
stream input function[
^]: it reads characters from the stream until, in your case, the character
'\n'
is read (it doesn't store those characters anywhere, unlike other input functions, but it examines and counts them).
While any error flag is raised, input functions do not read any characters (they do
a few other things[
^], but they aren't relevant here). Once the flag is cleared with
cin.clear()
, cin.ignore (or getline(cin, str), or cin.get() or any other input) can proceed.