quick fscanf question

This is a discussion on quick fscanf question within the C Programming forums, part of the General Programming Boards category; Hi - Just trying to read in strings from a file and I'm coming across a problem. In the file ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    24

    quick fscanf question

    Hi -

    Just trying to read in strings from a file and I'm coming across a problem. In the file I have

    Filenames
    triangle.txt

    And I want to miss out the Filenames and just read the triangle.txt but I've forgotton how to tell the program to skip that bit of text. I was trying to just add \n but it didnt like that at all.

    Any ideas??

    Cheers,

    H

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So read the first line and discard it. Then continue on your merry way.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You can do it with a single fgets():
    Code:
    char s[SIZE];
    fgets(s, sizeof(s), fp);
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. quick question (adding characters)
    By Cactus in forum C Programming
    Replies: 2
    Last Post: 09-24-2005, 03:54 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM

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