J
John Bode
My .dat file will contain information like below.
///////////
First
0x04
0x05
0x06
Second
0x07
0x08
0x09
Third
0x0E
0x0F
0x0D
///////////
In my main program, it will open this dat file, read line by line.
When it hits the string I'm searching for (e.g. "First"), the program
will know that the next line will be the variables to be stored. Are
there any C function to read file line by line? Please give me some
clue. Thanks a lot.
Abby.
As others have mentioned, fgets() is a good starting point, but it
needs some supporting logic to handle various errors and edge
conditions. If you *know* that your input file will always be
well-formed and that all lines will always be less than so many
characters long, then you don't need too much else, but to handle the
general case of unknown line length, premature EOF, and the like, you
need to do some additional work.
To convert your data values from strings to ints, use strtol().