What does this cin.clear() and cin.ignore() means?

this is the part of the code :

while(1) { 
      cout<<"Enter the Product ID :";
                      cout << "\t\t\t\t\WRONG ID DATA!" << endl;
                      cin.clear(); //what does it means??
                      cin.ignore(1000, '\n'); //why 1000??

thank you for helping....

Clear clears the failbit (a flag (bit) that was set to true when your used typed in a letter for your id instead of a number). cin.fail() is what checks the bits to see if the failbit has been set and returns true if it was. At that time that it fails, the stream is no longer valid to take more input. Clear allows you to reset this failed state and once again take input into your stream.

Ignore in that case discards up to 1000 characters or until it reaches a newline (whichever comes first).

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.