Apr 19, 2009 at 9:10pm UTC
can anyone please tell me when and how do we use cin.ignore(); ??
Apr 19, 2009 at 10:15pm UTC
I don't know the ins and outs but it has something to do with when the user inputs something and presses enter it leaves a '\n' that needs to be ignored.
Would also be interested in knowing the full reason for this to!
Apr 19, 2009 at 10:33pm UTC
Do you mean that this does not move the cursor to the second line when we press enter ?
Apr 19, 2009 at 11:14pm UTC
No i mean that say you have a program that asks you to input a number and you input the number 1, i think the program see's it as 1\n.
What cin.ignore() does is remove the '\n' from the input, as this is the default delimeter. You can specify otherwise.
Again, please correct if I am wrong!
Apr 19, 2009 at 11:23pm UTC
I dont know if you are right or wrong .
Apr 19, 2009 at 11:53pm UTC
There is a reference section on this site that is quite informative. You want to find the section for istream::ignore.