ZFGC

Resources => Coding => Topic started by: Hero of Vortex on August 02, 2006, 06:25:44 pm

Title: (C++) What's this thing do?
Post 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?
Title: Re: (C++) What's this thing do?
Post by: Ben on August 02, 2006, 06:28:05 pm
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.
Title: Re: (C++) What's this thing do?
Post by: TheDarkJay on August 02, 2006, 06:46:53 pm
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.
Title: Re: (C++) What's this thing do?
Post by: aab on August 02, 2006, 06:54:48 pm
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
 

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved