Page 1 of 1

need help with managing data in unsigned length arrays

PostPosted: Mon Apr 25, 2011 3:49 pm
by bleok
Hi
I need to save clone indexes of destroyed Actors in int * type array, but i cant find how to get size(length) of this array or number of last added element, something which help to use it in for loop.
Code: Select all
int * indexes;
int n;
for ( n = 0; n < LengthOF(indexes) ; n++ ){
indexes[n] = something;
}


If you know what to use instead of LengthOF in these lines, please tell me.

Re: need help with managing data in unsigned length arrays

PostPosted: Mon Apr 25, 2011 3:58 pm
by Game A Gogo
I think it's sizeof() but it returns the number of bytes it uses I think try googling about it

Re: need help with managing data in unsigned length arrays

PostPosted: Mon Apr 25, 2011 4:17 pm
by bleok
thanks for quick response. with your guess about sizeof i found answer really fast. not tested yet, but it seems to be like this:
Code: Select all
int * indexes;
int n;
for (n = 0; n < sizeof(indexes)/sizeof(*indexes); n++){
indexes[n] = something;
}