填空题

下列给定程序中,函数fun()的功能是:从字符串s中,删除所有小写字母’c’。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构.
试题程序:
# include <stdio.h>
void fun(char *s)
int i, j;
for(i=j=0; s[i] != ’\0’;i++)
if(sill != ’c’)
/********************************/
s [j] =s [i];
/**************found*************/
s[i]=’\0’;
main ()
char s[80];
printf ("\nEnter a string: ");
gets (s);
printf("The original string: ")
puts (s);
fun (s);
printf("The string after deleted: ");
puts (s); printf ("\n\n "):

【参考答案】

错误:s[j]=s[i]; 正确:s[j++]=s[i];
(2)错误:s[i]=‘\0’; 正确:s[j]=‘\0’;