#include <stdio.h>
void removeChar(char* str, char ch) {
int i, j;
int len = strlen(str);
for (i = j = 0; i < len; i++) {
if (str[i] != ch) {
str[j++] = str[i];
}
}
str[j] = '\0';
}
int main() {
char str[100],ch;
printf("\tDelete Character");
printf("\n====================================\n\n");
printf("Enter The String : ");
gets(str);
printf("\nEnter The Character To Replace : ");
scanf(" %c",&ch);
removeChar(str, ch);
printf("\n-------------------------------------\n");
printf("\nString After Removing %c : %s\n",ch, str);
printf("\n-------------------------------------\n");
return 0;
}
ch
from the input string by iterating through the string and copying each character that is not equal to ch
to a new string.main
function, the user is prompted to enter a string and a character to remove.removeChar
function is called with the string and character arguments, and the resulting string with the specified character removed is printed to the console.