Which method can be used to read one line at a time from a file in C?
I am using the fgets function, but it\'s not working. It\'s reading the space
The fgets
function will read a single line from a file or num
characters where num
is the second parameter passed to fgets
. Are you passing a big enough number to read the line?
For Example
// Reads 500 characters or 1 line, whichever is shorter
char c[500];
fgets(c, 500, pFile);
Vs.
// Reads at most 1 character
char c;
fgets(&c,1,pFile);