【发布时间】:2012-01-28 03:39:47
【问题描述】:
我对这个回复感到困惑。谁能帮助我并指出我在哪里犯了错误?键盘的输出是“memory clobbered before allocated block”
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char *s = (char *)malloc(10 * sizeof(char));
s = "heel";
printf("%s\n",s);
printf("%c\n",s[2]);
printf("%p\n",s);
printf("%d\n",s);
free(s);
return 0;
}
【问题讨论】: