5
Contributors
8
Replies
10
Views
10 Years
Discussion Span
Last Post by Bench
0

You've heard of if / else statements haven't you?

Try using them:

if (good)
  then
    //do stuff
  endif

elseif (bad)
   then
     //ignore and carry on
   endif
0

yes of course i know the if statment.
there's an ignore function
ignore (.... , .... );
this function 2 ignore some data from the input stream.
u can choose 3 or 4 chars for example 2 ignore them . i'm asking how i can use it. with an example

0

ignore() is member of the istream class. It will ignore char stored in the input stream buffer. It is commonly used as part of an overall data validation process, but it can be used in other circumstance as well.

I agree, a better description/example of what the OP is trying to do will make it more apparent whether the istream ignore() method is what they want or whether they would be better writing a parsing algorhithm of sort, etc., as iamthwee initially suggested.

0

there's an ignore function
ignore (.... , .... );
this function 2 ignore some data from the input stream.

It looks like they mean the standard cin.ignore function.

Why do you need to ignore three chars? Do you want to flush the input buffer?

0

i found it
it's ignore(int,char)
the 1 st parameter is the number of inputs that 'll b ignored.
the 2nd is the char which the input will b ignored till this char.
which comes first.

in my program i used cin.ignore(100,'\n');
and so i ignored the rest of the line.


in fact i need 2 read the 1 st 3 inputs from each line and the rest of the line in neglected so i do the flowing:

int i,j,k;
while(cin)
{
cin>>i>>j>>k;
cin.ignore(100,'\n');
}


it works good
each line i got the right inputs with neglecting the rest of the line.
my input stream is something like that:
6 8 9 khjgaguw gvmdvjfvnjnv sjbsdhkb.
8 66 0 b dbnfdhbfdjknbdmh9

0

what is the flash input buffer?
if u don't mind 2 explain for me

He said "Flush the input buffer" meaning empty all the data from the input stream.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.