detect EOL in C using fgets
15,985
Solution 1
fgets reads a string, and the result type is char*
I'd think you are thinking of fgetc
instead?
Solution 2
Why don't you try fgetc instead? Then you can compare the ASCII code of '/n' like this
while (fgetc (file) != '\n'){
puts(c);
}
Comments
-
Skizit almost 2 years
I'm attempting to read a single line from a file using the following...
while(fgets(c,BUF,f) != EOL){ puts(c); }
Where EOL =
#define EOL '\n'
however, I get the warning...comparison between pointer and integer
What is the correct way to achieve what I'm trying?