Get the length of the array in C:
/*
Example: get the array length in C language
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
int arr[] = {-1, 0, 1, 2, 3, 4};
int size= sizeof arr/ sizeof arr[0];
printf("The number of elements is: %d",size);
return(0);
}
output:
The number of elements is: 6