I wanted to ignore all characters in cin
to flush cin
in this answer: How to get rid of bad input one word at a time instead of one line at a time?
But I found that the program seemed to hang awaiting input if I wrote:
cin.ignore(std::numeric_limits<std::streamsize>::max());
It propperly flushed cin
if I used the '\n'
delimiter:
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
My question is, why can't I just ignore till EOF? Why do I have to provide the delimiter?