Ah, the always pleasant homework problem.
Welcome newbie. We don't do your homework, but lets take a simple look at that fscanf() function.
As I whip out my old C book, I see the format of the fscanf() function:
fscanf(input stream, control string, . . . ); |
That is quite nice.
Seeing as strings are stored as character arrays in C, there is no other way to store them.
There are a few ways you could go about reading a line from the file.
1) Assuming each line is a set number of bytes, simply read that entire line into a char.
2) Using a looping structure to (a) read until a newline character is encountered, or (b) until EOF.
I'm going to assume each line length is not know, so number 2 would work best in this situation.
In this situation, the code to read the character would be:
fscanf(infile, "%c", line);
So, you have fscanf reading a character from infile to the line array.
If you want to try method (1):
fscanf(infile, "%24s", line);
This will reads in a line of 24 characters to the variable line array.
So, you've got that going on for yah. Now it's up to you to figure out the rest.