请补充函数fun,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。 例如:当str1=“cdef
请补充函数fun,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。
例如: 当str1=“cdef",str2=“cde”时,函数fun()返回“>”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include< stdio, h>
include<conio. h>
define N 80
char *fun (char *str1,char *str2)
{
char *p1=str1, *p2=str2;
while (*p1 & & *p2 )
{
if (【 】)
return "<";
if(【 】)
return ">";
p1++;
p2++;
}
if (*p1=*p2)
return "==";
if (*p1==【 】)
return "<";
else
return ">";
}
main()
{
char str1 [N], str2 [N];
clrscr ();
printf ("Input str1: \n");
gets (str1);
printf ("Input str2: \n");
gets (str2);
printf ("\n*****the result*****\n");
printf ("\nstr1 %s str2", fun (str1, str2) );
}