C function - ftell ()

I don't understand why I am getting this weird result with this function with some files.

For example, if I have

input.txt

and inside it there is a line like

ABCD

if i do something like:

FILE* file = fopen("intput.txt", "r");
char currentChar;
long n = ftell(file); //return 0 it ok
fread(&currentChar, sizeof(char), 1, file);
long n = ftell(file); // return 1 it ok

      

Now if I do the same thing, but with (for example) a .png file, I have a different result:

FILE* file = fopen("intput.png", "r");
char currentChar;
long n = ftell(file); //return 0 it ok
fread(&currentChar, sizeof(char), 1, file);
long n = ftell(file); // return 216 why return 216 and not 1 

      

I don't understand why with the input.png file I get 216 instead of 1

+3


source to share





All Articles