3条回答 默认 最新
- qfl_sdu 2021-07-01 18:22关注
代码如下:
#include <stdio.h> int fun(char* s,char c) { int j; while(*s != '\0') { if(*s == c) { j=0; while(*s != '\0') { *s = *(s+1); s++; } s--; *s = '\0'; return 1; } s++; } return 0; } int main() { char buf[100]={0},c; int index = 0; int isvalid = 0; gets(buf); while(buf[index] != '\0') { if(buf[index] == ' ' && buf[index+1] != '\0') { isvalid = 1; c = buf[index+1]; buf[index] = '\0'; break; } index++; } if(!isvalid ) { printf("input eror,end\n"); return 0; } if(fun(buf,c)) printf("%s\n",buf); else printf("The string does not contain character '%c'\n",c); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报