代码:
#include <stdio.h>char *filter_ch(char *str, char ch){int i = 0, j = 0; // for pri string and new stringwhile (str[i]){if (str[i] != ch){str[j] = str[i];j++;}i++;}str[j] = '\0'; // remember the '\0'return str;
}int main() {char str[] = "Hello, World!";char ch = 'o';printf("Original string: %s\n", str);char *result = filter_ch(str, ch);printf("Filtered string: %s\n", result);return 0;
}