array length c
snippet in c

size of an array c

user6774

int a[20];
int length;
length = sizeof(a) / sizeof(int);

string length c

user2824

#include <stdio.h>
#include <string.h>
int main()
{
    char a[20]="Program";
    char b[20]={'P','r','o','g','r','a','m','\0'};

    // using the %zu format specifier to print size_t
    printf("Length of string a = %zu \n",strlen(a));
    printf("Length of string b = %zu \n",strlen(b));

    return 0;
}

array length c

user1262

int prices[5] = { 1, 2, 3, 4, 5 };

int size = sizeof prices / sizeof prices[0];

printf("%u", size); /* 5 */

get length of array in c

user8941

int a[17];
size_t n = sizeof(a)/sizeof(a[0]);