// This program reads two numbers from a file. #include #include #include using namespace std; int main() { string filename = "some_numbers.txt"; int num1, num2; ifstream infile; // instantiate file pointer object infile.open(filename); // associate file with file pointer object if (!infile) { cout << "Error opening file." << endl; return 1; // exit program with error code } cout << "Reading from file ... "; infile >> num1 >> num2; infile.close(); // close the file! cout << "Done!" << endl; cout << "The first two numbers in the file are:" << endl << num1 << endl << num2 << endl << endl; return 0; }