Mar 24, 2009 at 10:12pm UTC
hello, why everybody puts
Some people say that cin can leave a terminating character in the stream. Well, i didnt understand that. What problems can it origin? give examples, please..
Mar 24, 2009 at 10:56pm UTC
Hell if I know, that makes no sense.
Mar 24, 2009 at 11:01pm UTC
No, i mean, for example you have an integer x. you do:
cin >> x; cin.ignore();
Everybody use this, and i dont know why...
Mar 24, 2009 at 11:04pm UTC
cin leaves the newline character in the stream. Adding cin.ignore() to the next line clears/ignores the newline from the stream.
This is used mainly with combinations of cin and getline. I can't think of any examples but over time you will find them if you use getline and cin together.
Take a look at this:
Mar 24, 2009 at 11:16pm UTC
thanks a lot, you helped me...
Mar 25, 2009 at 12:18am UTC
will flush the input stream, just like C
, which is great for removing the annoying new lines stored at the end of the stream :P
Topic archived. No new replies allowed.
General C++ Programming
© cplusplus.com, 2000-2015 - All rights reserved -
Spotted an error? contact us