I wanted to know how excatly feof() works. I write some simple progrma to chek it out but results are far away from I expected. Here is a code
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE* infile = fopen("obrazek.bmp","r");
int a;
while (feof(infile) != 0)
{
fread(&a, sizeof(a),1, infile);
//int n = feof(infile);
printf("%i",a);
};
fclose(infile);
return 0;
}
Why feof() return 0 if I only opened a file? How to easily checked that i hitted end of a random file?