C Library Function - strlen()
Description
C Library Function **size_t strlen(const char *str) ** computes the length of the string str up to the null terminator, but not including the null terminator.
Declaration
Below is the declaration of the strlen() function.
size_t strlen(const char *str)
Parameters
- str -- the string whose length is to be computed.
Return Value
This function returns the length of the string.
Example
The following example demonstrates the use of the strlen() function.
#include
#include
int main ()
{
char str[50];
int len;
strcpy(str, "This is runoob.com");
len = strlen(str);
printf("|%s| 的长度是 |%d|\n", str, len);
return(0);
}
Let's compile and run the above program, which will produce the following result:
|This is runoob.com| 的长度是 |18|
C Standard Library -