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