C String Function : strlen()

The strlen() function is used to get the length of the string. It returns the length of string. The syntax is :
size_t strlen ( const char * str );
Example :
strlen(str);
The strlen() function counts the number of characters in a given string and returns the integer value and it stops counting the character when null character is found, because it indicates the end of the  string.

Example C Program :
#include <stdio.h>
#include <string.h>

int main() {
  char str[] = "Hello world, This is String.";
  int len;

  len = strlen(str);

  printf("Length : %d\n", len);
  return 0;
}
Output :

Length : 28

Note : We have to include the string.h header in our program to use the string function.

Links :