| End of File |
[29 Sep 2005|01:36pm] |
Hi, everyone.
I'm working on some code that finds the end of the file to decide what record number to give the next record, and I'm getting some weird behavior. My code looks like this:
fstream reqt("requests.dat", ios::binary | ios::out | ios::in | ios::ate); if (reqt.bad()) { cout << "\nUgh!\n"; exit(-1); } /* ... ... ... */ reqt.seekg(0,ios::end); a = (reqt.tellg() / sizeof(dRequest)); reqt.close();
tellg() is returning -1. Any ideas why? The file exists and is longer than 0 bytes. Other code in the same program can read from and write to the file correctly, but this bit doesn't work. Any help will be greatly appreciated.
|
|