Chapter 12 File Operations - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Chapter 12 File Operations

Description:

... File. Before data can be written to or read from a file, the file ... Closing a File. Always close a file when the program is finished with it. Infile.close ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 8
Provided by: cathe67
Category:

less

Transcript and Presenter's Notes

Title: Chapter 12 File Operations


1
Chapter 12 File Operations
2
Opening a File
  • Before data can be written to or read from a
    file, the file must be opened.
  • ifstream InputFile
  • InputFile.open(customer.dat)

3
Testing for Open Errors
  • DataFile.open(info.dat, iosin)
  • if (DataFile 0)
  • cout ltlt Error opening file.\n
  • return

4
Testing for Open Errors
  • DataFile.open(info.dat, iosin)
  • if ( !DataFile)
  • cout ltlt Error opening file.\n
  • return

5
Closing a File
  • Always close a file when the program is finished
    with it.
  • Infile.close( )

6
The get Member Function
  • InFile.get(Ch)

7
The put Member Function
  • OutFile.put(Ch)
Write a Comment
User Comments (0)
About PowerShow.com