C语言程序:从字符串中删除指定字符(区分大小写)
#include <stdio.h> #include <string.h>
void fun(char s[], int c) { int len = strlen(s); int i, j = 0; for (i = 0; i < len; i++) { if (s[i] != c && s[i] != c - 32 && s[i] != c + 32) { s[j] = s[i]; j++; } } s[j] = '\0'; }
int main() { static char str[] = "turbocandborlandc++"; char ch; printf("原始字符串:%s\n", str); printf("输入一个字符:"); scanf("%c", &ch); fun(str, ch); printf("str[]=%s\n", str); return 0; }
原文地址: https://www.cveoy.top/t/topic/pbnn 著作权归作者所有。请勿转载和采集!