I was just curious; what exactly does the line cin.ignore(INT_MAX) actually do? I was always told to use it just to keep the program screen up when inputting something.

It ignores the input.

It removes up to INT_MAX characters from the input buffer, basically clearing the buffer.

It removes up to INT_MAX characters from the input buffer, basically clearing the buffer.

Couldn't understand. Please simplify the use of it.

From this thread by Narue

#include <ios>
#include <istream>
#include <limits>

void ignore_line ( std::istream& in )
{
  in.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
}

The ignore member function of std::istream will read and discard up to N characters or until a delimiter. In the above example, N is represented by the largest value of the streamsize data type, and the delimiter is a newline. It works equally well with just a large value (80 is common):

in.ignore ( 80, '\n' );
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.