内存管理问题

xiaofeng_yan xiaofeng_yan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
/*test.c*/
#include <stdio.h>
#include <stdlib.h>
#define SIZE 16
int main ()
{
char *p;
p = malloc (SIZE*sizeof(char));
free(p);
p[0] = 'a';
printf("%c\n",p[0]);
return 0;
}


gcc test.c生成a.out
[yxf@localhost mem]$ ./a.out
a
这是什么原因,我已经在程序中先free了阿?
...全文
评论 9
收藏 已收藏
分享
返回顶部
xiaofeng_yan
C语言 70,039 成员 243,237 内容