Seeking positions in a file
The Seek() function is useful for setting the file cursor in a specific location. By default, it starts at offset 0 and moves forward as you read bytes. You might want to reset the cursor back to the beginning of a file or jump directly to a specific location. The Seek() function allows you to do this.
Seek() takes two parameters. The first one is distance; you want to move the cursor in bytes. It can move forward with a positive integer, or backward in a file if a negative number is provided. The first parameter, the distance, is a relative value, not an absolute position in the file. The second parameter specifies where the relative point starts and is called whence. The whence parameter is the point of reference ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access