count array's length in C
Code snippet on how to count array's length in C
int size;
int array[10] = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55};
size = sizeof(array) / sizeof(array[0]);
The code starts by creating a new integer variable called “size”. This variable will be used to store the length of the array. Then we create an array of integers of size 10, and assign some values to it. After that, the code finds the size of the entire array and divides it by the size of a single element in the array. This value is then stored in the “size” variable. This value represents the number of elements in the array, or the length of the array.