Need help with test file I/O

This is a discussion on Need help with test file I/O within the C Programming forums, part of the General Programming Boards category; I'm trying to read from a text file with the format "string1, string2,..string5" all separated by spaces, 158 lines in ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    2

    Exclamation Need help with test file I/O

    I'm trying to read from a text file with the format "string1, string2,..string5" all separated by spaces, 158 lines in lenght. I need to take each string and copy it into variables contained in a structure. Can anybody show me how this can be done efficiently?
    Thanks!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    Use fgets() to read each line in turn from the file
    Then perhaps strcpy to copy each word to members of your structure

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    2
    Salem,
    Thanks. I'm stil uncertain of how to implement what you suggested. An example would be great.
    jj

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Here. Read how fgets works.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File I/O Assertion Failure in VS2008
    By clegs in forum C Programming
    Replies: 5
    Last Post: 12-25-2008, 04:47 AM
  2. Subtle(?) File I/O Problem
    By cecomp64 in forum C Programming
    Replies: 9
    Last Post: 07-16-2008, 12:39 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

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