c语言函数strlen()作用是返回字符串长度



c语言函数strlen()作用是返回字符串长度。怎么获取字符串的长度。引入的头文件:#include <string.h>

如何定义strlen()函数:size_t strlen (const char *s);

strlen()函数使用介绍:strlen()用来计算指定的字符串s 的长度,不包括结束字符”\0″。

strlen()函数返回值:返回字符串s 的字符数.

strlen()函数实例源码介绍:取得字符串str 的长度。
#include <string.h>
main(){
char *str = “12345678″;
printf(“str length = %d\n”, strlen(str));
}

执行结果:
str length = 8