Seek
Moves the pointer to the current file position as specified. Seek enables random access within a file.
LONG Seek( LONG lOffset, UINT nFrom )
If the current file position is valid, seek returns the number of bytes from the beginning of the file otherwise an exception is thrown.
EX1
void file_Seek_ex1() { file ff("C:\\float.txt", file::modeCreate | file::modeWrite); vector<float> vf(5); for ( int ii = 0; ii < vf.GetSize(); ii++ ) vf[ii] = ii*1.25; ff.WriteFloat(vf, sizeof(float), vf.GetSize()); LONG lCurrent = ff.Seek(20, file::begin); // lCurrent = 20. lCurrent = ff.Seek(16, file::current); // lCurrent = 20 + 16 = 36. lCurrent = ff.Seek(-16, file::end); // lCurrent = length of file -16 = 4. ff.Close(); }
file::GetPosition, file::SeekToBegin, file::SeekToEnd
origin.h