第一题:请补充fun函数的功能是在字符串的最前端加入n个*号,形成新串,并且覆盖。
注意:字符串长度最长允许为79。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所写的若干表达式或语句。
#include
#include
#include
void fun(char s[], int n)
{
char a[80], *p;
int i;
p = ___1___;
for (i=0; i
a[i] = '*';
do
{
a[i] = ___2___;
i++;
} while (___3___);
a[i] = 0;
strcpy(s, a);
}
考试大(www.Examda。com)
main()
{
int n;
char s[80];
printf("\nEnter a string:");
gets(s);
printf("\nThe string\"%s\"\n", s);
printf("\nEnter n(number of*):");
scanf("%d", &n);
fun(s, n);
printf("\nThe string after insert:\"%s\"\n", s);
}
参考答案:
填空题:第1处填空:s
第2处填空:*p++
第3处填空:*(p) 或*p 或者 *p!=0