#include <stdio.h>
#include <string.h>
char removech(char* a,char b);
int main() {
char a[12];
char b;
scanf("%s\n",a);// important is \n
scanf("%c\n",&b);
removech(a,b);
printf("%s",a);
}
char removech(char* a,char b){
int c,i,j;
c=strlen(a);
for(i=0;i<c;i++){
if(a[i]==b){
for(j=i;j<c;j++){ //ddrrsh if we dont add it
//string by shifting the characters to the right of the current character a[i] one
//position to the left. Starting the loop from j=i ensures that only the
//characters to the right of the current character are shifted and modified,
//leaving the characters to the left of it unchanged.
a[j]=a[j+1];//imp
}
//c--;//its ok if no
//i--;
}
}
}
#if 0
int main(){
char a[10];
scanf("%s",a);
int size = strlen(a);
for(int i=0;a[i]!='\0';i++){
if(a[i]=='a'){
for(int j=i;a[j]!='\0';j++){
a[j]=a[j+1];//imp
}
}
}
printf("%s",a);
}
int main(){
char a[10];
scanf("%s",a);
int size = strlen(a);
int j = 0;
for(int i=0;i<size;i++){
if(a[i]!='a'){
a[j++]=a[i];
}
}
a[j] = '\0';
//The line a[j] = '\0'; sets the character at position j to the null terminator,
//which is used to indicate the end of a string in C. This ensures that the
//string stored in a is properly null-terminated, which is necessary for
//functions like printf to work correctly with the string.
printf("%s",a);
}
#endif
To embed this program on your website, copy the following code and paste it into your website's HTML: