Seek

Seek (as used in 'C') sets the file "cursor", which is where the next read and/or write will happen.

The two most important file postioning functions are:

  1. ftell(filehandle)
    which returns the current cursor position in the file stream.

  2. fseek(filehandle,position,origin)
    which moves to the specific position.
    "position" may be +/-
    "origin" may be:
    • "from the start of file" (SEEK_SET)
    • "from the current position" (SEEK_CUR)
    • "from the end of file" (SEEK_END)

    Positioning the cursor past the end of file is valid, and will write zeros to the intermediate characters.
    Positioning the cursor before the start of the file is just plain daft