未知题型
请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。 例如,输入“abcdefg”,指定字符为“d”,则输出“abe”。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。 试题程序: include<stdliB.h> include<stdio.h> define M 80 void main { int i=0; char str[M]; char ch; system('CLS'); printf('\n Input a strin9:\n'); gets(str); printf('\n Input a charator;\n'); scanf('%c',&ch); while(str[i]!=\0) { if(str[i]==ch) 【1】 【2】 ; } str[i]=【3】 ; printf('\n***display string***\n'); puts(str); }
A.h>B.h>
【参考答案】
【1】break;【2】i++【3】\0
【解析】题目要求删除指定字符后的所有字符,将字符串中的字符从第一个开......
(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
点击查看答案
相关考题
