主观

下列给定的程序中,函数proc的功能是:判断字符ch 是,与str所指字符串中的某个字符相同;若相同,则什么也不做,若不同,则将其插在串的最后。请修改程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序:

#include

#include

#include

#include

//****found****

void proc(char str,char ch)

{

while(*str &&*str!=ch)str++;

//****found****

if(*str==ch)

{ str[0]=ch;

//****found****

str[1]='0':

}

}

void main

{

char str[81],ch;

system("CLS");

printf("\nPlease enter a string:");

gets(str);

printf("\n Please enter the character to

search:");

ch=getchar;

proc(str,ch);

printf("\nThe result is%s\n",str);

}

参考答案
您可能感兴趣的试题
¥

订单号:

遇到问题请联系在线客服

订单号:

遇到问题请联系在线客服