C strlen Function: Purpose & Usage
The strlen function is used to calculate the length of a string, which is the number of characters in the string excluding the terminating null character ‘\0’. Its function prototype is:
size_t strlen(const char *str);
str is a string that ends with null.
The return value of the strlen function is an unsigned integer (size_t type), indicating the length of the string. For example, for the string “hello”, the strlen function returns 5. It can be used to determine the length of a string and iterate through each character in a loop.