zizi21
asked on
how is seek_set implemented ?
Hi there,
How is seek_set implemented ? Using seek_cur makes the code fast. When I look up seek_set, it says that it begins from position "0" (start of the file).
For instance, if its position is at 140 and I want to go to 150, seek_set would start from the start of file. This means, it would go from 140 to 0. Then, from 0 to 150. Why is seek_set behaving like that? Isn't more effecient to make another 10 steps from 140 to 150 (which i pressume to be the behaviour of seek_cur).
Many thanks.
How is seek_set implemented ? Using seek_cur makes the code fast. When I look up seek_set, it says that it begins from position "0" (start of the file).
For instance, if its position is at 140 and I want to go to 150, seek_set would start from the start of file. This means, it would go from 140 to 0. Then, from 0 to 150. Why is seek_set behaving like that? Isn't more effecient to make another 10 steps from 140 to 150 (which i pressume to be the behaviour of seek_cur).
Many thanks.
http://linux.die.net/man/2/lseek
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does this mean that fseek is a linux implementation and not a C implementation ? Thanks.
ASKER
I mean fseek is a C library implemenation but how is it implemented by linux ? The description of seek_set , seek_cur is what I explained in the question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the explaination. The thing that is confusing is that I did some code to compare the efficiency of seek_set and seek_cur. The code with seek_set takes a much longer time to execute than seek_cur.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.