老玉米 ·
·
阅读: 379
$ cat test.c
struct TempData{
int i;
char str[10];
long l;
};
int main(int argc, char **argv)
{
struct TempData *pd = 0;
pd = (struct TempData *) malloc(sizeof(struct TempData));
pd->i = 100; /* core dump here */
strcpy(pd->str, "hello");
pd->l = 200;
free(pd);
pd = 0;
return 0;
}
$ xlc -q64 -g -o test test.c
$ ./test