Best way to read lines out of a text file
Hi. If i've got a text file like:
--------------
filename1\n
filename2\n
filename3\n
--------------
and want to read a line at a time out of that file into say a buffer
is this the an ok way to do that? or is there a better way?
Code:
char buffer[100];
FILE *fp;
int c;
do {
c = fscanf(fp, "%s", filename);
dosomething_withfilename();
} while (c != EOF);
Oh, and am I right in assuming that fscanf appends NULL to the ends of the lines it
reads into the buffer?
thanks :)