ZFGC
Resources => Coding => Topic started by: Hero of Vortex on August 02, 2006, 06:25:44 pm
-
I found something called cin.ignore on Cprogramming.com, but it seems to do the same thing as cin.get. What's the difference?
-
I'd take a guess at cin.ignore will do the crazy thing of waiting for a response and then ignore it, whilst cin.get() will store it.
But I dunno to be perfectly honest.
-
I'm not sure, but I think it works like this:
cin.get() will get a charecter from the cin buffer
cin.ignore() will IGNORE the charecter, so if you call cin.get() you will get the next charecter after the ignored one.
But like I said, I'm not sure.
-
ignore( count, terminate )
Will ignore count input characters until terminate is found (terminate is ignored as well):
Go to: http://www.cplusplus.com/ref/
cin is an instance of the class istream, so click the istream box, and that displays the methods that cin can call, adn their meanings.
It defaults to ignore( 1, EOF ) which basically ignores the next character whatever value it is, as even if it is EOF, it will ignore it then stop as 'terminate' was found, and if it isnt, it will ignore one character then stop as it has fullfilled count==1