An array of structs or even a linked list would work.
struct data { char line[LEN]; } array[SIZE];
or
struct data { int code; char title[LEN]; } array[SIZE];
Read from the file until you don't have any more lines:
Code:
while ( fgets( array[i].line, sizeof( struct data ), IN ) != NULL ) {
/* Parse the line and process */
i++;
}
or
while ( fread( array[i], sizeof( struct data ), 1, IN ) != 0 ) {
/* Process each struct as you read it */
i++;
}
Try to stay away from using feof() as your conditional for stopping the loop, you'll end up reading one line too many and the last struct will probably be garbage.
Too tired, need sleep...
-Prelude