#include #include #include int main() { const int MAXLENGTH = 21; // maximum file name length const int MAXCHARS = 80; // maximum line length char file1[MAXLENGTH] = "prices.dat"; char line[MAXCHARS]; int ch; ifstream inFile; inFile.open(file1, ios::nocreate); if (inFile.fail()) // check for successful open { cout << "\nThe file was not successfully opened" << "\n Please check that the file currently exists." << endl; exit(1); } cout << endl; // start on a new line // now read the file while( (ch = inFile.peek()) != EOF ) { inFile.getline(line,MAXCHARS,'\n'); cout << line << endl; } inFile.close(); cout << endl; return 0; }