fscanf question

This is a discussion on fscanf question within the C Programming forums, part of the General Programming Boards category; Hey I got a question about fscanf. If I got a text file that got 3 lines (one number each ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    4

    Question fscanf question

    Hey I got a question about fscanf.

    If I got a text file that got 3 lines (one number each line) and I do:
    Code:
    fscanf(ftext,"%d",&firstnumber);
    fscanf(ftext,"%d",&secondnumber);
    fscanf(ftext,"%d",&thirdnumber);
    Does each fscanf will read one line ?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by SPIRIT6666
    If I got a text file that got 3 lines (one number each line) and I do:
    Code:
    fscanf(ftext,"%d",&firstnumber);
    fscanf(ftext,"%d",&secondnumber);
    fscanf(ftext,"%d",&thirdnumber);
    Does each fscanf will read one line ?
    It will appears to do so, leading whitespace (including the newline on the previous line) is ignored.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fscanf in different functions for the same file
    By bchan90 in forum C Programming
    Replies: 5
    Last Post: 12-03-2008, 08:31 PM
  2. Quick question about fscanf
    By zyphirr in forum C Programming
    Replies: 16
    Last Post: 11-24-2008, 08:44 PM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  4. quick fscanf question...
    By Ham in forum C++ Programming
    Replies: 4
    Last Post: 02-01-2003, 07:47 AM
  5. fscanf() question
    By Encrypted in forum C Programming
    Replies: 6
    Last Post: 01-20-2003, 12:14 PM

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