
sub(char *s) {char *p=a;while (*p) p++;return(p-s);} main() {char a[]="abcdefg";
2个回答
展开全部
int sub(char *s)
{
char *p=s; //这里LZ写错了,应该是s
while (*p) p++; //p转到串尾
return(p-s); //意思就是返回字符串的长度
}
char a[]="abcdefg"; //a中有7个字符,其长度为7
所以,输出结果为:7
{
char *p=s; //这里LZ写错了,应该是s
while (*p) p++; //p转到串尾
return(p-s); //意思就是返回字符串的长度
}
char a[]="abcdefg"; //a中有7个字符,其长度为7
所以,输出结果为:7
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询