Pass a value greater than the maximum long type value for fseek in C

I need to pass some values ​​to a method fseek()in C that are larger than the maximum value of the signed long type (2147483647). But if I do something lower, then the value of the result is -1, which is not successful. Anyway, can I do this?

//fp is the pointer to fopen method
unsigned long long index=2147483648;
int status = fseek(fp, index, SEEK_SET);
+5
source share
2 answers

Since you noted this with "Objective-C," I assume that you are also thinking of a Macintosh.

Check outfseeko (which accepts a 64-bit number).

+9
source

You need to use the 64 bit version fseek():

lseek():

lseek64(), , @R.. (. ), .

+6

All Articles