填空题
请补充fun函数,该函数的功能是:逐个比较a、b两个字符串对应位置中的字符,把ASCII值的或相等的字符依次放在到C数组中,形成一个新的字符串。
例如,若a中的字符串为aBCDeFgH,b中的字符串为:ABcd,则c中的字符串应为:aBcdeFgH。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
#include
#include
void fun(char *p, char *q, char *c)
{
int k =0 ;
while (*p||*q)
{
if (*p < *q)
c[k] = *q;
else
c[k] = *p;
if (*p)
p++;
if (*q)
q++;
k++;
}
}
main()
{
char a[10] = "aBCDeFgH", b[10] = "ABcd", c[80] = {'\0'};
fun(a, b, c);
printf("The string a:");
puts(a);
printf("The string b:");
puts(b);
printf("The result:");
puts(c);
}