char * func() {
char p[] = "hello world";
return p;
}
void main() {
char * p = func();
printf(p);
getchar();
}
为什么输出乱码?
void func(char*p)
{
p = (char*)malloc(100);
strcpy(p, "hello world");
}
void main()
{
char *p = NULL;
func(p);
printf(p);
getchar();
}
为什么程序终止?