Transferred from: http://blog.sina.com.cn/s/blog_679f85d40100mysi.html
Let's talk about the function of fseek () in C language:
function prototypes: int fseek (FILE *fp, LONG offset, int origin)
Parameter meaning: FP file pointer offset relative to Origin specified offset position the starting position of the origin pointer movement, can be set to the following three cases: Seek_set file start position seek_cur file Current location seek_end file end Location
Seep () and SEEKG () functions in C + +
SEEKP: Setting the file stream pointer location for the output file stream
SEEKG: Setting the file stream pointer location for the input file stream
Function Prototypes:
ostream& SEEKP (Streampos POS);
ostream& SEEKP (Streamoff off, Ios::seek_dir dir);
istream& seekg (Streampos POS);
istream& seekg (Streamoff off, Ios::seek_dir dir);
function parameters
POS: New file stream pointer position value
OFF: Values that need to be offset
Dir: Where to start the search
The dir parameter is used to locate the file stream pointer, representing the starting position of the search
enumerated types defined in iOS:
Enum Seek_dir {Beg, cur, end};
Meaning of each enumeration constant:
Ios::beg: Where to start the file stream
Ios::cur: Current location of the file stream
Ios::end: End location of the file stream
Usage of SEEKG () and SEEKP () in C + + FStream