hi,
what is the use of cin.ignore()? i am new to C++ i have idea about C,
thanks@@@@@@@@@@@@@@@
hi,
what is the use of cin.ignore()? i am new to C++ i have idea about C,
thanks@@@@@@@@@@@@@@@
it causes characters in the input buffer to be read and discarded.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
something like getch()?
no not really...
consider it like this....
when you use cin>> the newline is left in the stream rather than discarded so if you then try a cin.get() or a cin.getline() it will appear that that statement was skipped because all it picked up was the newline and so we can use cin.ignore() to ignore the last character in the input buffer. It can be useful for removing bad input from the buffer to.
cin.ignore() by default ignores 1 char. You can also use it like this...
cin.ignore(100,'\n') this will ignore up to 100 chars or a newline whichever comes first.
Thats about all there is to cin.ignore()
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi