Fixing issues with cin.clear() & cin.ignore()

No it will only skip the next entry.

So if you entered 1 2 3 4 5.
1 2 3 will go to the cin variables for guess values, 4 will be ignored and 5 will go to the next iteration GuessA value.

Here you must pass atleast a 2 to skip 4 and 5 i.e. cin.ignore(2) will ignore next 2 entries

So a better way is to enter cin.ignore(’\n’) which will ignore entries until a new line is reached which by default is present at the end of the input stream

1 Like

could you elaborate on what is error status

Privacy & Terms