1.

Is There Any Function That Can Skip Certain Number Of Characters Present In The Input Stream?

Answer»

Yes! This can be DONE using cin::ignore( ) function. The PROTOTYPE of this function is as shown below:

istream& ignore ( int n = 1, int d =EOF );

Sometimes it happens that some extra characters are left in the input stream while TAKING the input such as, the '\n' (Enter) character. This extra character is then passed to the next input and may pose problem.

To get rid of such extra characters the cin::ignore( ) function is used. This is equivalent to fflush ( stdin ) used in C language. This function IGNORES the first n characters (if present) in the input stream, STOPS if delimiter d is encountered.

Yes! This can be done using cin::ignore( ) function. The prototype of this function is as shown below:

Sometimes it happens that some extra characters are left in the input stream while taking the input such as, the '\n' (Enter) character. This extra character is then passed to the next input and may pose problem.

To get rid of such extra characters the cin::ignore( ) function is used. This is equivalent to fflush ( stdin ) used in C language. This function ignores the first n characters (if present) in the input stream, stops if delimiter d is encountered.



Discussion

No Comment Found