Home > Article > Backend Development > Detailed explanation of strlen usage in C language
Detailed explanation of strlen usage in c language:
The function of strlen() function is to count the length of a given string.
Function prototype: unsigned int strlen(char *str);
Function: Count the number of characters in the string str, excluding '\0'
Return value: Return the number of characters
Example:
char *str1 = "abcdef"; // 定义一个字符指针 char str2[] = "abcdef"; // 定义一个字符数组 int len = strlen(str1); // 统计str1字符的个数,结果为6 int len = strlen(str2); // 统计str2字符的个数,结果为6
Recommended tutorial: "c"
The above is the detailed content of Detailed explanation of strlen usage in C language. For more information, please follow other related articles on the PHP Chinese website!