cfopenfgetpos

c fgetpos giving wrong position


I am new to C and I have this code:

f = fopen( argv[1], "rb" );
fseek( f, 64, SEEK_SET );
fpos_t pos;
fgetpos (f, &pos);
printf("%x", pos);

However, this returns 40, even though it's supposed to be returning 64. What am i doing wrong?


Solution

  • Because you're using %x. It's saying 40 as in 0x40, the hexadecimal number. You need %i or %d to get a decimal number.