#include #include int main() { const int MAXLENGTH = 21; char filename[MAXLENGTH] = "test.dat"; char ch; long offset, last; ifstream inFile(filename); inFile.open(filename, 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); } inFile.seekg(0L,ios::end); // move to the end of the file last = inFile.tellg(); // save the offset of the last character for(offset = 1L; offset <= last; offset++) { inFile.seekg(-offset, ios::end); ch = inFile.get(); cout << ch << " : "; } inFile.close(); return 0; }