strlen()

This function counts the number of characters present in a string.
Hence, strlen() function return always numeric value.

syntax:

strlen("Any_string");

example:

strlen("C Program");

It return : 9

The following program illustrated the uses of strlen() function as:


/*c program to illustrate the use of strlen function*/
#include<stdio.h>
int main()
{
 int len;
 char str[40];
 printf("Enter any string : ");
 gets(str);
 len = strlen(str);
 printf("%s = %d Characters",str,len);
 getch();
 return 0;
}

The output of above program would be:


Output of illustrate strlen() function C program
Figure: Screen shot for illustrate of strlen() function

Related program:

  1. list of standard library string function
  2. strcpy()

Comments