In the example shown above, the length of the string str is 6.
In this tutorial, first, we will show how to use a user defined function to calculate length of a string, and then we will show you a built-in library function strlen(). We also show you the uses of the sizeof operator for string literals.
String Length Using User Defined Function
You can write a user defined function which returns the number of characters in a string.
int stringLength(char *str)
while(str[i] != ‘