第1个回答 2011-06-16
字符串a的长度为:9
Press any key to continue
#include <stdio.h>
int main()
{
int len=0;
char a[]="how long?";
char *p;
p=a;
while (*p)
{
len++;
p++;
}
printf("字符串a的长度为:%d\n",len);
return 0;
}
第2个回答 2018-12-19
//给定字符串"hello world",如何计算出它的实际有效字符的长度。
#include<stdio.h>
int main()
{
int len=0;int i=0;
char array[]="hello world";
while(array[i])
{
len++;
i++;
}
printf("%d",i);
}
第3个回答 2011-06-16
unsigned int strlen(const char *str)
{
unsigned int len=0;
while(str[len]) ++len;
return len;
}