C library functions -strlen()
C Standard Library - <string.h>
Description
C Library Functionssize_t strlen(const char *str) Calculate StringstrThe length, up to but not including the null terminating character.
Declaration
Below is the declaration of the strlen() function.
size_t strlen(const char *str)
Parameter
- str-- The string whose length is to be calculated.
Return Value
This function returns the length of the string.
Example
The following example demonstrates the usage of the strlen() function.
#include <stdio.h>
#include <string.h>
int main ()
{
char str[50];
int len;
strcpy(str, "This is example.com");
len = strlen(str);
printf("|%s| 的长度是 |%d|\n", str, len);
return(0);
}
Let us compile and run the above program, which will produce the following result:
|This is example.com| 的长度是 |18|other extensions