字符串数组怎么获取其中字符串的长度

2025-04-09 12:46:30
推荐回答(1个)
回答1:

在C语言中使用函数strlen()就可以了,以下面的程序为例

#include
#include
#include
int main()
{
char string[]="hello,world";
int length;
length=strlen(string);
printf("the string is:%s\n",string);
printf("the length is:%d\n",length);
return 0;
}

运行结果如下,如果有什么不明白的还可以问我