|
 |
Darren New wrote:
> stbenge wrote:
>> will work just fine elsewhere. Any help would be appreciated. I'm
>> really stumped :(
>
> Step one of being un-stumped is to figure out which of your assumptions
> in the code is not holding true.
>
> Print out fieldFileName.
> Print out fieldFile.
> Print out tempFx, tempFy, and val each time through the loop.
> Print out the return values from fread.
> print out sizeof(val).
>
> The question you seek to answer is whether val is being read
> incorrectly, or whether it's the assignment that is failing.
Thanks! I made my project a console application and printed the values
as you suggested. I found out that by not explicitly assigning "val" (or
tempFx, tempFy) an initial value, it was picking up nonsense and
carrying it through as it read through the stream. I do not know why it
would act this way inside a class member but not in other scenarios, but
I suspect it has to do with how C++ allocates memory.
> I also wonder why you read tempFx and tempFy and then don't use them for
> anything. I'm assuming this is some header?
Yes. The first two values in the binary file(s) describe the width and
height of a playing field for a game. I dumped the values into useless
variables so I could step through them without actually needing them,
and wind up at the correct point in the stream to start reading values
into the array. I may need to use these values another time, so I left
that functionality in the binary format.
> Showing the declaration of the rest of the class (including map) is
> probably a good idea.
I'm not sure I need to, now :)
Sam
Post a reply to this message
|
 |