给定程序函数fun的功能是:比较两个字符串,将长的那个字符串的首地址作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
不要改动main函数,不得增行或删行,也不得更改程序的结构!
#include <conio.h>
#include <stdio.h>
/**********found**********/
char fun(char *s, char *t)
{
int s1=0, t1=0;
char *ss, *tt;
ss=s;
tt=t;
while(*ss)
{
s1++;
/**********found**********/
(*ss)++;
}
while(*tt)
{
t1++;
tt++;
}
if (t1>s1)
{
return t;
}
else
{
return s;
}
}
main()
{
char a[80],b[80];
printf("\nEnter a string:");
gets(a);
printf("\nEnter a string again:");
gets(b);
printf("\n\nThe longer is:\n\n%s\n",fun(a,b));
system("pause");
}