Chapter 15 File I/O
So far the only way in which we have interacted with our computer programs is through user input, typed in using the keyboard at runtime. But there are other ways in which to make your code react to your own data. For example, you may have a file in which you are storing your grades and which you’d like to use as input to a program that calculates your GPA. We’ll learn about working with files in this chapter. Specifically, we will focus on the following topics:
- How to write data to a file
- How to read data from a file
- How to check whether we have reached the end of a file (read all of the data in the file)
- How to check whether a file is actually open for reading (yes, you read that right: you have to first get a file ready for reading in order to then read from it).