need help with managing data in unsigned length arrays

Non-platform specific questions.

need help with managing data in unsigned length arrays

Postby bleok » Mon Apr 25, 2011 3:49 pm

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.
bleok
 
Posts: 8
Joined: Sun Mar 06, 2011 2:31 pm
Score: 0 Give a positive score

Re: need help with managing data in unsigned length arrays

Postby Game A Gogo » Mon Apr 25, 2011 3:58 pm

I think it's sizeof() but it returns the number of bytes it uses I think try googling about it
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: need help with managing data in unsigned length arrays

Postby bleok » Mon Apr 25, 2011 4:17 pm

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;
}
bleok
 
Posts: 8
Joined: Sun Mar 06, 2011 2:31 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest