Some help with the "File Handling".....please!!

This is a discussion on Some help with the "File Handling".....please!! within the C Programming forums, part of the General Programming Boards category; Hi..I got stuck with file handling.. how can I get the each line's string from the file..?? I mean..for example, ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    4

    Talking Some help with the "File Handling".....please!!

    Hi..I got stuck with file handling..
    how can I get the each line's string from the file..??
    I mean..for example, if I have file which contain

    2--->how many countries participate
    canada
    united states
    2,1-->these are score for the game

    then, how can I store each line into array??
    like ["2","canada","united states", "2,1"]

    the file format always like that, but I should handle 2 team to 256 teams..so..anyway..anybody knows how to handle the file like this??

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Use fgets to read a line at a time into an array. Once there, parse the array and copy its contents wherever you need to. I suggest you use something like strncpy for the copying.

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

Popular pages Recent additions subscribe to a feed

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