int turning into a location or double?!?

so i'm running into this problem with this code.

1
2
3
4
5
6
7
8
9
10
11
//TestCode is a class
TestCode * enemies[100];
int nullPoint;
for (int some = 0;some < 100;some++)
{
	if (enemies[some] == 0)
	{
		nullPoint = some;
		break;
	}
}


nullPoint is returning something that looks like -8105230. if I test some before the if statement it returns an int. what's going on here?!? :(
if TestCode is a class, do you really intend to have this comparison: enemies[some] == 0 ?
nope, but i need a way to check if i've instantiated an instance of the class into a slot in the pointer array.
Last edited on
nullPoint is uninitialized and no enemies equals 0.

Try to do something like it:
1
2
3
4
5
int nullPoint = -1;

//loop

if (nullPoint == -1) cout << "No enemies";
nullPoint is returning something that looks like -8105230


these are old values on the stack; (values of dead variables which no longer exist)
to get rid of this initialize array with some numbers or zerros.
Last edited on
1
2
TestCode * enemies[100];
memset( elements, 0 , sizeof( element ) ) ; 
Topic archived. No new replies allowed.