C语言编程:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。

如题,求大神解答

#include <stdio.h>
int func(char *s)
{
char *p=s;
while(*p)p++;
return p-s;
}
int main(void) 
{
char str[100];
gets(s);
printf("%d\n",func(str));
return 0;
}

温馨提示:答案为网友推荐,仅供参考
相似回答