So I have a textfile with 10 words with 5 characters each, and I want to get to the midpoint of that file without having to call read multiple times so I wanted to use lseek. As I understand, lseek only uses the SET, CUR, and END flags.
So If I have a textfile and all the words are only 5 words long...
I can use SEEK_SET
to get the current word I'm at which would be 5
I can use SEEK_CUR
to get to the next word location, so 10, then 15 and so on
I can use SEEK_END
to get to 100.
My question is, if I want to get somewhere in between, say spot 76 or 24, or in my case 50, how can I do that? I tried doing using lseek with SEEK_SET / 2 and it doesn't work.