2014年计算机二级C语言考试上机模拟试题(4)_第6页
三、程序改错题(共24分)
下列给定程序中,函数proc( )的功能是:从字符串str中,删除所有大写字母’F’。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main( )函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include
void proc(char*str)
{
int i,j;
//****found****
for(i=j=0;str[i]一’0’;i++)
if(str[i]!=’F’)
//****found****
str[i]=str[i];
str[j]=’\0’;
}
void main( )
{
char str[80];
printf("\nEnter a string:");
gets(str);
printf("The original string:");
puts(str);
proc(str);
printf("The string after deleted:");
puts(str);
printf("\n\n");}
相关文章
- 2014-02-10
- 2014-02-10
- 2014-02-10
- 2013-06-24
- 2013-06-24
- 2013-06-07
- 2013-06-07
- 2013-06-07