The current position or file pointer in a file is the location where the next read or write operation will occur. To change the current position in an open file, use the mmioSeek function. The mmioSeek function has the following syntax:
LONG mmioSeek(hmmio, lOffset, iOrigin)
The hmmio parameter specifies the file handle for the file.
The lOffset parameter specifies an offset for changing the current position in the file.
The iOrigin parameter specifies how the offset given by lOffset is interpreted. If iOrigin is SEEK_SET, the offset is from the beginning of the file. If it is SEEK_CUR, the offset is from the current position. If it is SEEK_END, the offset is from the end of the file.
The return value is the new position, specified in bytes from the beginning of the file. If an error occurs, the return value is -1. If you seek to an invalid location in a file, such as past the end of the file, mmioSeek might not return an error, but subsequent I/O operations can fail.
To seek to the beginning of an open file, use the following:
mmioSeek(hFile, 0L, SEEK_SET);
To seek to the end of an open file, use the following:
mmioSeek(hFile, 0L, SEEK_END);
To seek to a position ten bytes from the end of an open file, use the following:
mmioSeek(hFile, -10L, SEEK_END);