Answers for "find the length of array of string in c"

C
5

how to find length for string in c

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

    // 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;
}
Posted by: Guest on October-01-2020
0

find length of array in c

int a[17]; // initializing an array
int length = sizeof(a)/sizeof(a[0]); // divide array size(in byte)/ size of the first element of the array of the same type, here int(integer size is 4byte)
Posted by: Guest on July-30-2021

Code answers related to "find the length of array of string in c"

Code answers related to "C"

Browse Popular Code Answers by Language