使用函数返回字符串,自动变量被销毁,导致乱码,

在删除一个字符串中的指定字母,如:字符串 "aca",删除其中的 a 字母。这一C语言程序编写时,出现乱码。后发现

是使用了指针访问被销毁的局部变量。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char* deleteChar(char *ca, char c)
{
    static char retc[50];///加入static将其放在全局变量区
    //printf("%s
",retc);
    char *rc;
    int j = 0;
    while(*ca != '