Finding String Length

Learn how to calculate the length of the string in this lesson.

To help programmers work with strings effectively, C library provides several functions, like strlen( ), strcpy( ) , strcat( ), strcmp( ), etc. Without these library functions, we would need to develop parallel functions ourselves.

The strlen() function

strlen( ) returns the length of the string, i.e., the number of characters present in the string, excluding the null terminating character.

The basic syntax of the strlen() function is given below:

int strlen(const char *stringName);

Here, stringName points to the string whose length is to be found.

Get hands-on with 1400+ tech skills courses.