...but a better way is to always use a constant to define the array size, for example: ...
Not to be too much of a nitpick, but I don't think that it is always "better". Sometimes you really do just want to be able to add add a string/value/object in an array initializer and let the computer figure out how many of them there really are. sizeof is annoying but you only have to get it right once.
Hi DCB, since we're nitpicking, the point was that a constant is better than a value inserted into the body of the code as per the OP's fragment.
i.e. the code in reply #1
#define MY_SIZE 5
int myarray[MY_SIZE];
for( int i=0 i < MY_SIZE; i++)
myarray = i ;
Is better than
int myarray[5];
for( int i=0 i < 5; i++)
myarray = i ;