Cin.ignore (numeric_limits <streamsize> :: max (), '\ n')

What does this particular line of cin.ignore(numeric_limits<streamsize>::max(), '\n') mean in C ++ programming? Does this actually ignore the last user login?

+14
c ++ ignore cin
source share
2 answers

This line ignores the rest of the current line, up to '\n' or EOF - whichever comes first:

  • '\n' sets the delimiter, that is, the character after which cin stops ignoring
  • numeric_limits<streamsize>::max() sets the maximum number of characters to ignore. Since this is the upper limit of the stream size, you effectively tell cin that there is no limit to the number of characters to ignore.
+15
source share

cin.ignore (numeric_limits <streamsize> :: max (), '\ n');

Here, \n acts as a delimiter .... this is the point to which the code should be ignored (like "\ n" in this special case). And max() determines that there is no limit to how much you can ignore, spaces, tabs should be ignored until the end of the line.

0
source share

All Articles