C++ - Get current position of file pointer.
Hello,
I'm trying to get the file pointer position.
The result I'm getting is 4096 when I know its less.
I understand that the 4096 is probably the cluster size.
I know I can count the read sizes, just seems a bit clumsy,
How do I get the absolute position of the file pointer
when I've finished my reads, not always to the strucure end?
Regards
Code:
myStructure pt2[1];
FILE * in2 = fopen(tmp.c_str(), "r");
fseek(in2, 0x00, SEEK_SET); // go to start
fread(pt2, sizeof(myStructure), 1, in2); //structure
...various reads // all OK
long size = ftell (in2);
printf("pos - %lx - %u\n", size, size); // prints "pos - 1000 - 4096"
fpos_t pos;
fgetpos (in2, &pos);
printf("pos - %lx\n", pos); // prints "pos - 1000"