// ;----------------------------------------------------------- // ; Program Name: Class_Demo // ; File: demoprob11.cpp // ; Description: Demos C++ Record I/O Routines and the atol() function // ; Author: Jim Adams // ; Environment: MS C++ 6.0 // ; Date Written: 10/13/2001 // ;----------------------------------------------------------- #include #include #include char data[256]; long num; int counter=0; // Start of main logic void main(void) { ifstream file_of_numbers; file_of_numbers.open("c:/data/c_programs/cis162/fall2001/numbers.dat",ios::in | ios::nocreate); if (file_of_numbers.fail() != 0) { cout << "File Open Failed with Error Code: "; cout << file_of_numbers.fail() << "\n"; cout << "Program Aborting...\n\n"; } else { while (! file_of_numbers.eof()) { file_of_numbers >> data; num=atol(data); counter++; cout << data << " " << num << endl; } file_of_numbers.close(); cout << "Processed " << counter << " records" << endl; } }