fscanf: read words from file

Hi

I have a file like that:

1 2 3 4 5 6 7 8

and I want print on stdout:

1 3 8

in other words i want choose what print out.
I was thinking to use fscanf as:

fscanf(file_in,"%d %d %d",&a, &b,&c);

but in this way i get:
1 2 3
Is there a solution using fscanf to obtain my purpose?

Thanks
D

---------- Post updated at 11:08 AM ---------- Previous update was at 10:51 AM ----------

hi
I solved it. it enough to insert a format type indicator, something like:

fscanf(file_in,"%d %*1hd %d ",&a, &b,&c)

here the references fscanf - C++ Reference.

D.

scanf is generally considered unsafe, as is fscanf for similar reasons.

You're much better off learning how to use fgets and sscanf to do your work.

fscanf will continue to read %d from your stream, skipping whitespace and stopping when it can't read another one, so you could have read them in a loop, discarding the ones you didn't want.

thanks for your advice. I'll keep in mind and I'll try the solution you suggest

D.