Join Peggy Fisher for an in-depth discussion in this video File operations, part of Learning C++ (2014).
…Up until now, we have been reading data directly from the console.…This is good when we don't need to read a lot of data, but…there are many times where we need to read in large amounts of data.…Also, it would be helpful if we had the ability to run…the program multiple times without needing to re-enter all the data every time.…This is where we benefit from the file operations available in C++.…We can read from a file, write to a file, and add data to an existing file.…By adding the directive, #include <fstream>, we have access to…all the file libraries for reading, writing, and creating files.…
In this program, we're going to read in 20 possible…replies to a random question asked by the user.…I'm using a file, so I can easily change the answers.…This can also be used to create your own fortune teller program.…Let's start by taking a look at the file that I created.…It's called replies.txt.…If I open the file, you can see there's 20 different replies here.…To create a file you can create a file in…any text editor or you can create it within C++.…
- Downloading and exploring the C++ IDE
- Working with loops
- Using predefined functions
- Creating custom functions
- Creating and instantiating classes
- Working with external files
Skill Level Beginner
Q: How do I upgrade the C++ compiler on Mac OS X and Linux?
A: Refer to C/C++ Essential Training for a detailed look at installing or upgrading the C++ compiler on various platforms.
Q: The link to download the Eclipse IDE in the "Download a C++ IDE" movie doesn't work. Where can I find the IDE?
A: Short URLs are case sensitive and need to be typed in exactly as they appear. Type in or simply click http://goo.gl/CzckWp to visit the Eclipse IDE for C/C++ Developers page.
1. Getting Started
2. C++ Basics
3. Flow of Control
4. Classes and Objects
5. Data Structures
6. File Manipulation
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.