C – Strlen

C – Strlen 2017-07-19T22:32:17+00:00


Syntax :
#include < string.h>
size_t strlen( char *str );

strlen(char *str) returns the length of the null terminated string pointed to by str. The null terminator is not counted.

This function will return number of characters in the string provided as parameter to this function. For example if we are providing “The world” as the string it will return 9. That means it will take the blank spaces in between the words in the string into count. But the null terminator is not counted. It will aslo take special characters like @,#,$,% etc into count.

consider this example str[30]=”www.cprogrammingexpert.com”;

It is stored like

Here strlen(str) equals 26. null terminator is not counted.


Output :

str = www.cprogrammingexpert.com


Prev Next