C program to find the length of a string

c programming tutorial to find the length of a string

string_length.c

#include <stdio.h>
#include <string.h>
 
int main()
{
   char a[100];
   int length;
 
   printf("Enter a string to calculate it's length\n");
   gets(a);
 
   length = strlen(a);
 
   printf("Length of entered string is = %d\n",length);
 
   return 0;
}

Output


Enter a string to calculate it's length
DheerajSinghBhadoria
Length of entered string is = 20

0 comments:

Post a Comment

My Instagram