Home >Backend Development >C#.Net Tutorial >What does strlen mean in C language?
#What does strlen mean in C language?
The strlen function is a standard library function in C language. Its function is to calculate the length of a string, but does not include "\0".
Syntax and description
C library function size_t strlen(const char *str) calculates the length of the string str until the null terminating character, but does not include the null terminating character .
size_t strlen(const char *str)
Parameters
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 strlen() function.
#include <stdio.h> #include <string.h> int main () { char str[50]; int len; strcpy(str, "This is php.cn"); len = strlen(str); printf("|%s| 的长度是 |%d|\n", str, len); return(0); }
Let us compile and run the above program, which will produce the following results:
|This is php.cn| 的长度是 |14|
Recommended tutorial: "C#"
The above is the detailed content of What does strlen mean in C language?. For more information, please follow other related articles on the PHP Chinese website!