i want 2 use the ignore function 2 ignore some of my inputs data, but i dont know how
i'm using C++

Member Avatar for iamthwee

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

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

Member Avatar for iamthwee

Huh, do you have a better example?

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.

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?

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.