Beginner question about cin.ingore

Why is cin.ignore(1000, 10); used after cin >> variable; if the computer is executing in sequential order ? Isn't the computer supposed to know about the buffer (1000, x) and the enter key (x , 10) before the user even presses the enter key?

I'm trying to play computer and get a sense of how the computer thinks in that particular occasion.
cin.ignore(1000, 10);
Do not do that. '\n' literal is there for a reason. In particular your code will not work on older MacOS and it is not really friendly to Windows either.
Correct way is .ignore(std::numeric_limits<std::streamsize>::max(), '\n'); (because ignore has a special case for streamsize max)

Please exlain what do you mean. Because as I see it is logical: formatted extraction leaves unused symbols in input buffer. If we do not need them we must get rid of them.
Topic archived. No new replies allowed.