This is not a pure programming question, however it impacts the performance of programs using fseek(), hence it is important to know how it works. A little disclaimer so tha
One observation I have made about fseek
on Solaris, is that each call to it resets the read buffer of the FILE
. The next read will then always read a full block (8K by default). So if you have a lot of random access with small reads it's a good idea to do it unbuffered (setvbuf
with NULL
buffer) or even use direct syscalls (lseek
+read
or even better pread
which is only 1 syscall instead of 2). I suppose this behaviour will be similar on other OS.