File reading problem.. Please help.

Started by
10 comments, last by GameDev.net 18 years, 8 months ago
Quote:Original post by _Zido_
Okay, i found the problem, and its alot simpler than all the other solutions.

The problem is here:

int row;

I changed it to:

int row=0;

And poof, it works.
The problem was when i set the variable it probably gets set to NULL. You cant have an array which is NULL. And therefore the program crashed =]
Thanks for everyones help anyways.


If you use uninitialized variables, their value is unprediceable, and not always NULL. Besides NULL==0 unless you #define NULL something_else.
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Advertisement
The answer to this sort of problem is to set your warning level to maximum and don't ignore warnings. Ideally, force your compiler to treat warnings as errors.

Uninitialised variables are easily picked up by the compiler and it can save hours of debugging time.

This topic is closed to new replies.

Advertisement