File streams
ifstream
ofstream
fstream (we'll cover this much later)
Opening a file
Use a class constructor
Use the open function
Closing a file
Reading from a file
>> operator
getline
the string version
the cstring version (we'll cover this later)
get
Writing to a file
<< operator
put
Handling End of File (EOF)
Practice Exercise 2 Email only the source code for each practice exercise as an email attachment. There is no due date. Use "Practice Exercise 2" as the email subject. Add (a) comment(s) at the top of your program with your name, practice exercise #, your compiler and operating system. Write a program in which you read in this file, partially displayed below and write out another file containing every other integer value on each line. There are 50 lines in the input file and each line contains 15 integers. The integers in the output file should each be written in a field of width 9. Make sure you check for successful file opens. Hint: a "double for loop" should make the file processing easy. Input file
Output file
|