// this accurately obtains the size
int INTS[] = {1, 2, 3, 4, 5};
int length = sizeof INTS / sizeof INTS[0];
RESULT => length = 4
// this fails. returns the size of the pointer (4 bytes)
int* INTS_PTR = &INTS[0];
int length = sizeof INTS / sizeof INTS[0];
RESULT => length = 1
No comments:
Post a Comment