File Pointer: The File Pointer Indicates The Position in The File at Which The Next Input/output Is To Occur
File Pointer: The File Pointer Indicates The Position in The File at Which The Next Input/output Is To Occur
Moving the file pointer in a file for various operations viz modification, deletion, searching, etc.
following functions are used.
seekg() : it places the file pointer to the specified position in input mode of file
e.g. file.seekg(p, ios::beg); or
file.seekg(-p, ios::end); or
file.seekg(p, ios::cur);
i.e. to move to p byte position from beginning, end or current position
seekp() : it places the file pointer to the specified position in the output mode of file.
e.g. file.seekp(p, ios::beg); or
file.seekp(-p, ios::end); or
file.seekp(p, ios::cur);
i.e. to move to p byte position from beginning, end or current position
tellg() : this function returns the current working position of the file pointer in the input mode
e.g int p=file.tellg();
tellp() : this function returns the current working position of the file pointer in the output mode.
e.g int p = file.tellp();