这个小程序,不安全吗?解决办法

这个小程序,不安全吗?
其实本质是想问问在函数里面申请的字符数组返回给主函数之后,能不能接着进行操作?

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

#define MAX_BUF_SIZE 200

char *delete_the_last_char_of_(const char *src);

int main(int argc, char* argv[]){
char hello_world[]="Hello, world";
char *delete_hello=delete_the_last_char_of_(hello_world);
printf("%s",delete_hello);//输出啥?
//删除后对该字符指针进行任意可能的操作,比如:修改第一个字符
char *delete_hello2=delete_the_last_char_of_(delete_hello);
printf("%s",delete_hello2);//输出啥?
return 0;
}

//请看这个函数
char *delete_the_last_char_of_(const char *src){
chan des[MAX_BUF_SIZE];
int src_len=strlen(src);
memcpy(des,src,src_len+1);
//删除最后一个字符
des[len-1]='\0';
return des;
}
c

------解决方案--------------------
引用:
楼主 你的程序能编译通过吗?
这样改下 你的程序就可以了
C/C++ code?123456789101112131415161718192021222324252627#include <string.h>#include <stdio.h>#include <stdlib.h>  #define MAX_BUF_SIZE 200  char* delete_the……

内存泄露就是这么来的。
------解决方案--------------------
char des[MAX_BUF_SIZE]; 是在栈上的内存  函数执行完 就释放了。
char *des = (char *)malloc(sizeof(char) * MAX_BUF_SIZE); 是堆上的内存,是用户申请的内存,需要用户自己手动释放。
------解决方案--------------------
static 拯救楼主