Bill Scheremeta

sizeof operator to get indice to last element of array

Discussion created by Bill Scheremeta on Sep 14, 2006
Latest reply on Sep 18, 2006 by Bill Scheremeta
I cant seem to get the syntax right for the sizeof operator, or it is not implemented on CodeWarrior 5.1 for HCS08.
To get the number of bytes in an array of char called array_name, isn't it:
#define NUM_BYTES sizeof(array_name[])
I am using NUM_BYTES to determine how many elements are in the array. Of course I know this at compile time for my simple app, but if I add another element, I don't want to have to adjust all my for() loops that reference the array, ie
does not need to be updated if the array size is changed