填空题

请补充函数fun(),该函数的功能是;删除字符数组中小于等于指定字符的字符,指定字符从键盘输入,结果仍保存 例如,输入“abcdefghij”,指定字符为‘d’,则结果输出“defghij”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio. h> #define N 80 void fun (char s[], char ch) { int i=0, j=0; while (s [i] ) { if (s Iii<ch) 【1】 ; else { 【2】 i++; } } 【3】 } main () { char str [N], ch; clrscr (); printf("\n Input a string:\n"); gets (str); printf("\n*** original string ***\n"); puts (str); printf("\n Input a character:\n"); scanf ("%c", &ch); fun(str, ch); printf("\n*** new string ***\n"); puts (str); }

【参考答案】

[1]i++ [2]s[j++]=s[i] [3]s[j]=’\0’
热门 试题