I use this line to ignore all but one letter given to a variable through 'cin' (thanks to vlad for suggesting it): cin.ignore( numeric_limits <streamsize>::max(), '\n' );
But why the '\n' at the end? Everything else make sense, but not the '\n'. It irritates me... I like knowing why I type the things I do.
I don't know the context why did you need exactly these parameters, but: cin.ignore( numeric_limits <streamsize>::max(), '\n' ); means skip everything until a newline character is met ('\n'). If you want to ignore everything that is left in the buffer then call cin.ignore( numeric_limits <streamsize>::max() );
The function takes two arguments, the first is the amount of characters to ignore, the second is a delimiting character.
The stream will stop ignoring whichever one of these two is first met, meaning it will stop either after the specified amount of characters, or when it encounters a linebreak - whichever comes first.