C examples for Data Type:sizeof
The following code calculates how many elements are contained in an array by dividing the array size by the size of the array data type.
#include <stdio.h> int main()//from w w w .j a va 2s .co m { int array[10]; printf("\nSize of array: %d bytes\n", sizeof(array)); printf("Number of elements in array "); printf("%d\n", sizeof(array) / sizeof(int)); }