给定程序中,函数fun的功能是:比较两个字符串,将长的那个字符串的首地址作为函数返回值。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
char *fun(char *s, char *t)
{
int s1 = 0, t1 = 0;
char *ss, *tt;
ss = s;
tt = t;
while (*ss)
{
s1++;
ss++;
}
while (*tt)
{
t1++;
tt++;
}
if (t1 > s1)
return t;
else
return s;
}
int main()
{
char a[80], b[80];
printf("\nEnter a string: ");
gets(a);
printf("\nEnter s string again:");
gets(b);
printf("\nThe longer is:\n\"%s\"\n", fun(a, b));
getchar();
return 0;
}