dlong wrote:
PS: ftell() returns -1 if there's an error in the filestream.
It was fucking up because I was using "set equal to" (=) instead of "if equal to" (==) in my if statements (in a previous version, anyway).
I fixed that, then ditched the ftell by using if (!feof(ReadCursor)) instead (compliments to SubDrag for pointing that one out).
The while statement still isn't being executed though...I watched all the variables, and they look right. It's even opening the correct file (when I was still using the ftell, it was returning 4, which is indeed the file size). So the file must be opening correctly.
Maybe this beta version of Dev C++ doesn't compile while statements right? That sounds very unlikely.
Still, it just STOPS when it gets there. It doesn't continue on if the conditions aren't meant or execute if they are. It just craps out.
I wanted to try using a label/goto combo (I hear that's an ugly way of doing anything in C++) just to see if using an if instead of a while would make it work, but I don't know how to do that.
Here's what I have now, by the way:
Code:
[Removed (outdated)]
Edit: I tried it with a label (figures how to use labels would be so obvious) and an if, and it's actually executing now!
But it doesn't ever reach the end of the file. SubDrag said fread increments the read pointer. I think I read on
http://www.cplusplus.com that it does, too. But if it's incrementing, why isn't the end of file flag being set? It just keeps going and going...
I think I should cout an ftell and see wtf is going on.
Edit: It's outputting now. I just need to format the output width for the first two output variables to always be 8 digits and find a way to make the program terminate.
It is indeed incrementing the variable...I think what it's doing is returning to the beginning of the file if it reads past the end. That seems ridiculous. It should still set the eof flag if it does that. @_@