BY SONALI GHOLVE
 A file is collection of related data storage in
particular area on disk.
Output file stream
Read data
Disk
Files
C++ Program
input file stream
Data output
Write data
Data input
 Stream: Sequence of bits
 Input streams: Stream that supplies data to a
program.
 Output stream : Stream that receive data
from the program
 File stream: Input file and output file
collectively known as file stream
 IO stream:This stream used for both read and
write the data
 Open
 Close
 Read
 Write
 End of file
 Delete
 Update
 ios::app -> Append to end to file
 ios ::ate -> Go to end of file on opening
 ios ::binary ->Binary file
 ios ::in -> Open file for reading only
 ios :: nocreate ->Open fails if the file does not
exist
 ios ::noreplace-> Open fails if the file already
exist
 ios ::out -> Open file for writing only
 ios :: trunc ->Delete the contents of file if it
exist
 Input pointer (get pointer): Used when
reading the contents of file at the given
location.
 Output Pointer: Used when writing the
content into the given location.
 seekg() : Moves the get pointer to a specified
location.
Syntax : seekg(location);
 seekp():Moves the put pointer to a specified
location.
Syntax : seekp(location);
 tellg(): By using this function we can know the
current location of the get pointer.
Int curloc=ob.tellg();
 tellp(): By using this function we can know the
current location of the put pointer.
Int curloc=ob.tellp();
 Put() :Writes single character to the
associated stream
 Get() : Reads single character to the
associated stream
 Read() :To read a data in binary format
 Write() :To write a data in binary format
Thank you!!!!!!!!!
For any query please send me mail on
sonalisagargholve@gmail.com

File handling in c++

  • 1.
  • 2.
     A fileis collection of related data storage in particular area on disk. Output file stream Read data Disk Files C++ Program input file stream Data output Write data Data input
  • 3.
     Stream: Sequenceof bits  Input streams: Stream that supplies data to a program.  Output stream : Stream that receive data from the program  File stream: Input file and output file collectively known as file stream  IO stream:This stream used for both read and write the data
  • 5.
     Open  Close Read  Write  End of file  Delete  Update
  • 6.
     ios::app ->Append to end to file  ios ::ate -> Go to end of file on opening  ios ::binary ->Binary file  ios ::in -> Open file for reading only  ios :: nocreate ->Open fails if the file does not exist  ios ::noreplace-> Open fails if the file already exist  ios ::out -> Open file for writing only  ios :: trunc ->Delete the contents of file if it exist
  • 7.
     Input pointer(get pointer): Used when reading the contents of file at the given location.  Output Pointer: Used when writing the content into the given location.
  • 8.
     seekg() :Moves the get pointer to a specified location. Syntax : seekg(location);  seekp():Moves the put pointer to a specified location. Syntax : seekp(location);  tellg(): By using this function we can know the current location of the get pointer. Int curloc=ob.tellg();  tellp(): By using this function we can know the current location of the put pointer. Int curloc=ob.tellp();
  • 9.
     Put() :Writessingle character to the associated stream  Get() : Reads single character to the associated stream  Read() :To read a data in binary format  Write() :To write a data in binary format
  • 10.
    Thank you!!!!!!!!! For anyquery please send me mail on sonalisagargholve@gmail.com