Having simple text file like myfile1.txt:
cat myfile1.txt:
abc
and below code
# include <stdio.h>
# include <string.h>
# include <errno.h>
# include <unistd.h>
char mybuffer[80] = "abc\n";
char* result = NULL;
int main() {
        FILE* pFile;
        pFile = fopen ("myfile1.txt", "r+");
        int c;
        if (pFile == NULL)
                perror ("Error opening file");
        else {
                result = fgets(mybuffer, 80, pFile);
                if (feof(pFile)) {
                        printf("fgets EOF");
                }
                fclose (pFile);
                return 0;
        }
}
Why doesn't the function feof returns nonzero while the end of the stream has been reached (fgets gets 3 chars "abc" and hits EOF)?
 
     
    