C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-24-2009, 02:32 AM   #1
Registered User
 
Join Date: Jun 2009
Posts: 31
fscanf: read word 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
Dedalus is offline   Reply With Quote
Old 06-24-2009, 02:56 AM   #2
Registered User
 
Join Date: Jun 2009
Posts: 31
Hi

I got it
It's enough to insert a format type indicator, something like:

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

D
Dedalus is offline   Reply With Quote
Reply

Tags
file, fscanf

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Seg Fault in Compare Function tytelizgal C Programming 1 10-25-2008 03:06 PM
seg fault at vectornew tytelizgal C Programming 2 10-25-2008 01:22 PM
C++ std routines siavoshkc C++ Programming 33 07-28-2006 12:13 AM
Dikumud maxorator C++ Programming 1 10-01-2005 06:39 AM
simulate Grep command in Unix using C laxmi C Programming 6 05-10-2002 04:10 PM


All times are GMT -6. The time now is 04:59 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22