back
File Handling
This web page supplements chapter 11 of your book. You are now going to learn how to manipulate files in C++. So far, you have been storing information within the program itself. But what do you if you need to store thousands of pieces of information? If you are creating a database, you will need to store your data in a separate file. Your program will then need to know how to find and open that file so that you add or delete records from it. That's what this section of the course is all about.

Before you continue the activities on this webpage, go through the PowerPoint presentation in the public directory named "file basics."

Check out this first example.

Notice the use of the "if statement" to verify that the file really opened for output.

Assignment

Run the above program in your compiler. After you execute the program, open the file called "NAME_AGE.DAT" and verify that the data you input is there.

Assignment

Study this next example. Compile and execute it in your compiler and then verify that the data is in a file named "FLOATS.DAT."



Homework Assignment

  1. Read pages 206-213 in Knowlton.