FILE POINTERS AND
THEIR MANIPULATORS
-Megul raj
File Pointers
• The c++ I/O system supports four functions for
setting a file pointer to any desired position
inside the file or to get the current file pointer.
• These allow programmer to have control over a
position in the file where the read or write
operation takes place.
FUNCTION MEMBER OF CLASS
seekg() ifstream
tellg() ifstream
seekp() ofstream
tellp() ofstream
There are two pointers in the class fstream – the put pointer used for
writing and the get pointer used for reading
seekg()
Moves get file pointer(input)to a specified location.
Syntax:
seekg( offset, refposition);
tellg()
Gives the current position of the get pointer.
Syntax:
pos_type tellg ();
seekp()
Moves put file pointer(output)to a specified location.
Syntax:
seekp( offset, refposition);
tellp()
Gives the current position of the put pointer.
Syntax:
pos_type tellp ();
file pointers & manipulators.pptx
file pointers & manipulators.pptx

file pointers & manipulators.pptx

  • 1.
    FILE POINTERS AND THEIRMANIPULATORS -Megul raj
  • 2.
    File Pointers • Thec++ I/O system supports four functions for setting a file pointer to any desired position inside the file or to get the current file pointer. • These allow programmer to have control over a position in the file where the read or write operation takes place.
  • 3.
    FUNCTION MEMBER OFCLASS seekg() ifstream tellg() ifstream seekp() ofstream tellp() ofstream There are two pointers in the class fstream – the put pointer used for writing and the get pointer used for reading
  • 4.
    seekg() Moves get filepointer(input)to a specified location. Syntax: seekg( offset, refposition); tellg() Gives the current position of the get pointer. Syntax: pos_type tellg ();
  • 5.
    seekp() Moves put filepointer(output)to a specified location. Syntax: seekp( offset, refposition); tellp() Gives the current position of the put pointer. Syntax: pos_type tellp ();