C examples for Data Type:sizeof
To determine the length of a statically allocated array, the sizeof operator can be used.
#include <stdio.h> int main(void) { int myArray[] = { 1, 2, 3 }; /* alternative */ int length = sizeof(myArray) / sizeof(int); /* 2 */ printf("%d", length); }