Topic description:
Input string s and character c, request to remove all c characters in s, and output the result.
enter:
There are multiple sets of test data, each input string s and character c.
output:
For each set of input, output the result after removing the c character.
Sample input:
heallo
a
Sample output:
hello
See the program below:
#include<stdio.h> #include<string.h> intmain() { char c; char str[100]; printf("input a word: "); while(scanf("%s",&str)!='\n') { getchar(); printf("delete: "); scanf("%c",&c); for(int i=0;i<strlen(str);i++) { if(str[i]==c) continue; // If we point to a letter we don't want, just continue and jump out of this loop else printf("%c",str[i]); } } return 0; }
Screenshot of the program running: