// Attached: HW_6a
// ===========================================================
// File: HW_6a.cpp
// ===========================================================
// Programmer: Elaine Torrez
// Class: CS 1A
// ===========================================================
#include <iostream>
#include <fstream>
using namespace std;
// ==== main ===================================================
// This program reads numbers from the data.txt file and
// displays them on the screen.
//
// Input:
// data.txt - A text file containing integer values.
//
// Output:
// The numbers in the file are displayed on the screen.
// ===========================================================
int main()
{
ifstream inFile;
int number;
// open the file for reading
inFile.open("data.txt");
// check if the file opened successfully
if (!inFile)
{
cout << "Error opening file!" << endl;
return 0;
}
cout << "Here are the numbers in the file:" << endl;
// read and display each number in the file
while (inFile >> number)
{
cout << number << endl;
}
inFile.close();
cout << "Press any key to continue . . .";
cin.get();
return 0;
} // end of main()
// ===========================================================