When used on an array the sizeof operator will return its size in bytes. If you want the number of elements, you need to divide the size of the array by the size of one of its elements:
Code:
printf("size of my_array = %u\n", sizeof(my_array) / sizeof(my_array[0]));
Some programmers use a macro to make the code more readable:
Code:
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
printf("size of my_array = %u\n", ARRAY_SIZE(my_array));
The sizeof operator will return the size of an array that is declared in the current scope. When used on a pointer, it will return the size of a pointer, which is 4 bytes on most 32bit platforms.