hunchback
2012-03-21 07:35:00 UTC
I have a loop in my program which uses getline to get user input. So I have to use cin.ignore() at the top of the loop to flush the '\n' at the end of the last input, from the previous cycle of the loop.
The problem with that is, the first time the loop is encountered, there's nothing in the buffer, so the cin.ignore() statement just prints a blank line waiting for something to ignore, without any hint as to why it's doing this. Is there any way to insert a '\n' into the buffer at the beginning of the program, so the cin.ignore() ignores that, instead of waiting for the user to input something to ignore?