get the number of array elements in c language

‮//:sptth‬www.lautturi.com
get the number of array elements in c language

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
Created Time:2017-08-28 20:50:09  Author:lautturi