File Input and Output in C++
Course Overview
1h 15m

This course covers file input/output (file I/O). Being able to read from and write to secondary storage is important because often we want to keep some data persistently. By the end of this course, you will have the skills necessary to do this.

Learning Objectives

  • Understand the fundamentals of both file input and file output and how to use both in tandem
  • Use stream manipulators to make the structure of the data more organized
  • Use dynamic memory, pointers, and classes to make more complex and interesting applications

Intended Audience

  • Beginner coders, new to C++
  • Developers looking to upskill by adding C++ to their CV
  • College students and anyone studying C++


To get the most out of this course, you should have a basic understanding of the fundamentals of C++.


In this section, we will build a foundation for working with File I/O which is short for file input/output. Being able to read from and write to secondary storage is important because often we want to keep some data persistently. Also in many areas of computer science and related disciplines like data science, the data itself may just be too big to hold all of it in main memory, or we may simply want to reduce the amount of main memory we use at a given time, or it might be at a premium, there may not be that much available. For most traditional computer science and software engineering applications, however, our primary concern is data persistence. We want to simply be able to store data long term even after the program is done for a time or when the power is turned off on our computers. There are some great projects at the end of this section too. We will be working on a project where we read data from a file and print some statistics, one where we revisit our dynamic rectangles and this time send the data to the file, and also a project involving shopping items. All of this starts with learning about how to read and write from files. I'm excited to share this knowledge with you and hope that you see how incredibly important these skills are. So, put on your thinking caps and get ready to learn. I'll see you in the next lecture where we'll start our File I/O journey.

About the Author
Learning Paths

John has a Ph.D. in Computer Science and is a professional software engineer and consultant, as well as a computer science university professor and department chair.

Covered Topics