第31套
填空题
请补充fun函数,该函数的功能是:把主函数中输入的字符串str2接在字符串str1后面。
例如:str1=”How are”,str=”you ”,结果输出:How are you
注意:部分源程序给出如下
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
试题程序:#include
#include
#define N 40
void fun(char *str1, char *str2)
{
int i = 0;
char *p1 = str1;
char *p2 = str2;
while (___1___)
i++;
for (; ___2___; i++)
*(p1+i) = ___3___;
*(p1+i) = '\0';
}
main()
{
char str1[N], str2[N];
int m, n, k;
printf("******* Input the string str1 & str2*******\n ");
printf(" \nstr1:");
gets(str1);
printf(" \nstr2:");
gets(str2);
printf("******* The string str1 & str2*******\n");
puts(str1);
puts(str2);
fun(str1, str2);
printf("******* The new string *******\n");
puts(str1);
}
第1处填空:*(pl+i)或pl[i]或*(pl+i)!=0或pl[i]!=0
第2处填空:*p2或p2[0]或*p2!=0或p2[0]!=0
第3处填空:*p2++
编辑特别推荐: