可以用来求字符数组的元素个数
#include <stdio.h>
#include <string.h>
void main()
{
char psz[] = "abcd";
printf("%p\n",&psz[0]);
printf("%d\n",strlen(psz));
}
输出 4
本文介绍了一种使用 C 语言标准库函数 `strlen` 来计算字符数组中有效字符数量的方法。通过示例代码展示了如何正确获取字符串的实际长度。
2070

被折叠的 条评论
为什么被折叠?



