Week 7 - Advanced IO
Learning Objectives
Upon finishing this learning module, you should be able to:
- Read and write text-based files
- Format stream output
- Use exception handling for error management
Recommended Schedule
Day 1
- Read about Output Formatting (Ch 11.1-11.3)
- Start File IO and Streams (Ch 11.4-11.6)
Day 2
- Veteran's Day holiday
Day 3
- Start File IO and Streams (Ch 11.7-11.12)
- Learn about the Working Directory
- Start Ch 11 Exercise Set
Day 4
- Do Exception Handling reading (Ch 10.6-10.11)
- Checkout assignment
File IO and Streams
Read Ch 11 on File IO and Streams.
These optional videos reinforce the concepts from the reading:
Basic File Reading (11.5-11.6)
Using eof to read a full file (11.7)
Deciding on getline vs >> (11.8)
Using Stringstreams (11.10)
Working Directory
The working directory controls where your program will read and write files from. It is NOT always the same as the directory your program is in! Learn more about it in this video:
As the video explains, if your data file is in the same folder as your program, and you run the program from inside that folder, you should not need to worry about doing anything special. It only becomes an issue when your program is in one folder and your data file is in another.
Exception Handling
Read the second half of Ch 10 on Exception Handling (10.6-10.11).