Reading from a Text File
Next, let’s examine text file input. It’s based on console input, which has many elements. So let’s begin with a summary those elements:
• You must include the iostream header file.
• The iostream header file defines an istream class for handling input.
• The iostream header file declares an istream variable, or object, called cin.
• You must account for the std namespace; for example, you can use the using directive or the std:: prefix for elements such as cin.
• You can use cin with the >> operator to read a variety of data types.
• You can use cin with the get() method to read individual characters and with the getline() method to read a line of characters at a time.
• You can use cin with methods such as eof() and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access