The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-24-2009
Dedalus Dedalus is offline
Registered User
  
 

Join Date: May 2009
Location: Italy/France
Posts: 60
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:
Code:
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.