Hello everyone, i'm trying to print a file in reverse, to do this, I need to use random acccess file functions. My idea was to go to the last character and just print until I get to the first character of the file. To find the last character, which is really the start of the file, i thought i would tell the file market to go to the last character in the file, ios::end, and then travel to the beginning of the character, so the file marker should stop at the first character, put it all together and u get seekg(0,ios::end); here's my code
Code:
void reverseFile(ifstream& theCopy)
{
	char ch;
	int last;
	theCopy.seekg(0,ios::end);		//returns the size of the file
	last = theCopy.tellg();
	cout <<"Last: " << last << endl;

	for(int offset = 1; offset <= last; offset++)
	{
		theCopy.seekg(-offset,ios::end);
		ch = theCopy.get();
		cout <<ch;
	}
}
When i ouptut last, it says -1, which isn't right!
any idea's where I went wrong?
Thanks