I am using fgets to read a file line by line
char buffer[4096];
while (fgets(buffer, sizeof(buffer), file__1) != NULL) {
fprintf(file__2, "%s", buffer);
}
However the man page of fgets() says this under the Examples section
while (fgets(line, line_max + 1, fp) != NULL) {
// Verify that a full line has been read ...
// If not, report an error or prepare to treat the
// next time through the loop as a read of a
// continuation of the current line.
...
// Process line ...
...
}
My question is, upon fgets failing how could i "Verify that a full line has been read"?
getline(3), which doesn't have this issue because it reallocates the line buffer if needed. - Shawn