以下是C语言编写的代码实现:

#include <stdio.h>

void del(char *s, char c) {
    char *p = s;
    char *q = s;
    while (*q != '\0') {
        if (*q != c) {
            *p = *q;
            p++;
        }
        q++;
    }
    *p = '\0';
}

int main() {
    char str[100];
    char c;
    
    printf("请输入字符串:");
    gets(str);
    printf("请输入要删除的字符:");
    scanf("%c", &c);
    
    del(str, c);
    
    printf("删除后的字符串为:%s", str);
    
    return 0;
}

运行程序后,按照提示输入字符串和要删除的字符,即可得到删除后的字符串输出。

C语言实现字符串删除字符函数 del() - 不使用库函数

原文地址: https://www.cveoy.top/t/topic/bMgs 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录