Home >>C String functions >C strlen() function

C strlen() function

C strlen() function

Definition:

strlen() function returns the total length of the given string. It does not count null character.

Syntax:
Strlen(str)

Note:- Here str is given string.

Parameters:-

It takes string as parameter.

Return type:-

It returns total length of string.

Example-1

#include <stdio.h>
#include <string.h>
int main()
{
  char str[20] = "function";
  printf("Length of string: %d", strlen(str));
  return 0;
}

Output:
length of string: 8
Example-2

#include <stdio.h>
#include <string.h>
int main() 
{ 
   char str[]= "arya"; 
   printf("Length of string is: %d", strlen(str)); 
   return 0; 
} 

Output:
Length of string is: 4

No Sidebar ads