// Native_ReadTextFile.cpp : Defines the entry point for the console application. /* _____________________________________________________________________________ Learning C++: Lesson 5 File I/O: Reading a textfile Ron Kessler Created 1/4/2017 Native Version This little program shows how to read a simple text file. This little program shows how to work with File IO. The two data types are the ifstream and the ofstream. The names stand for input file stream and output file stream. A stream is just a bunch of data that you can read from or write to. What these types do is take a file and turn it into a long stream of data that you can access. Allain, Alex. Jumping into C++ (p. 411). Cprogramming.com. Kindle Edition. Run using CTL-F5 ___________________________________________________________________________ */ #include "stdafx.h" #include #include #include //add this so we can do File IO using namespace std; int main() { ifstream myReader ("customers.txt"); //open file for reading (i= input) string lineFromFile; if (myReader.is_open ()) //make sure file can be opened { while (getline (myReader, lineFromFile)) //read to end of file { cout << lineFromFile << '\n'; //print out each line } myReader.close (); //always close the file } else cout << "Unable to open file"; return 0; }