急!!!c语言fun函数求字符串长度

来源:百度知道 编辑:UC知道 时间:2024/06/06 21:06:51
用函数Fun求一个字符串长度,在main函数中输入字符串,并输出其长度!

#include "stdio.h"

int Fun(char *str)
{
char *p=str;
while(*p++);
return p-str-1;
}

void main()
{
char str[80];
gets(str);
printf("%d\n",Fun(str));
}

int Fun(char *s)
{
int i;
for(i=0;s[i]!='\0';i++)
;
return i;
}