UncleCoder.com

UncleCoder.com

Free programming examples and instructions

C program to study strlen() function

C program to study strlen() function

by Krishna


Posted on 27 Jun 2018 Category: C Views: 1600


C program to study strlen() function

The strlen() function calculates the length of a given string.  The function takes a single argument, i.e, the string variable whose length is to be found, and returns the length of the string passed.The strlen() function is defined in <string.h> header file. Below shows a sample program which uses the string function to find the length of a string

int main()
{
  char a[100];
  int length;
 
  printf("Enter a string :");
  gets(a);
 
  length = strlen(a);
 
  printf("Length of the string = %d\n", length);
 
  return 0;
}

 

OUTPUT



Leave a Comment:


Click here to register

Popular articles