题目内容:
下列给定程序中,函数proc()的功能是:从字符串str 中,删除所有小写字母c。请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也小得更改程序的结构。
试题程序:
#include<stdio.h>
void proc(char*str)
{
int i,j;
for(i=j=0;str[i]!='\0';i++)
if(str[i]!='c')
//****found****
str[j]=str[i];
//****found****
str[i]='\0 ';
}
void main( )
{
char str[80];
printf("\nEnter a strin9:");
gets(str);
printf("The original string:");
puts(str);
proc(str);
printf("The string after deleted:");
puts(str);printf("\n\n");
}
参考答案:【答案仅供学习,请勿对照自行用药等】
答案解析: