Function for manipulation of file pointer: –

Function for manipulation of file pointer: – The C++ I/O system support for function for setting a file pointer to any desired position inside the file or to get the file pointer. These allow the programmer to have control over a pointer in the file where read or write operation text place. These for function are listed below.

Function

Member of class

Action performed

Seekg() Ifstream Moves get file pointer to a specific location
Seekp() Ofstream Moves put file pointer to a specific location
Tellg() Ifstream Returns the current position of the get pointer
Tellp() Ofstream Returns the current position of the put pointer

The seekp() and tellp() are member function of ofstream. The seekg() or tellg() are member function of ifstream. The class fstream deals with file in both input and output modes. Hence, there are two file pointer in class fastream and the put pointer used for writing and get pointer used for the reading. Syntax of the seek function is –

<Stream Object>.seekg(long offset,seek_origin=ios::beg);
<Stream Object>.seekp(long offset,seek_origin=ios::beg);
Advertisements

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: