0% found this document useful (0 votes)
27 views

File Pointer: The File Pointer Indicates The Position in The File at Which The Next Input/output Is To Occur

The file pointer indicates the position in a file where the next input/output operation will occur. The seekg() and seekp() functions are used to move the file pointer to a specified position in the file for input or output mode, respectively, by indicating the byte position and reference point of beginning, end, or current position. The tellg() and tellp() functions return the current file pointer position for input or output mode.

Uploaded by

Abhinav Tripathi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

File Pointer: The File Pointer Indicates The Position in The File at Which The Next Input/output Is To Occur

The file pointer indicates the position in a file where the next input/output operation will occur. The seekg() and seekp() functions are used to move the file pointer to a specified position in the file for input or output mode, respectively, by indicating the byte position and reference point of beginning, end, or current position. The tellg() and tellp() functions return the current file pointer position for input or output mode.

Uploaded by

Abhinav Tripathi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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();

You might also like