strlen() - String Manipulation Function

How to find length of the string used in C++?

Explanation

strlen() manipulation function is used to find the length of a string between starting character and the terminating NULL character.

Syntax:


size_t strlen ( const char * str );

Example :



#include <stdio.h>
#include <cstring.h>
int main ()
{
char str1[50];
strcpy(str1,"My name is alex");
printf ("The length of str1 is:: %u\n",strlen(str1));
return 0;
}

Result :

The length of str1 is:: 15

In the above example, "strlen()" manipulation function is used to find the length of "str1".

C++ Tutorial


Ask Questions

Ask Question