I'm trying to read text from a file using stream variables and fscanf. This file has occasional empty lines, for example:
Code:
This is line 1.
This is line 2.
This is line 3.
This is line 4.
So far, I'm able to read everything from the file, save for the empty lines. So my output becomes:
Code:
This is line 1.
This is line 2.
This is line 3.
This is line 4.
This is the code I use for the actual reading (I'm using the while(!feof(FILE)) loop; I know it's bug-prone but that's what we were taught):
Code:
fscanf(FILE, "%[^\n]\n", Line);
printf(" %s\n", Line);
My question is, how do I read the empty lines?