#include <stdio.h>
char * a(void)
{
char p[]="hello world";
return p;
}
void main(void)
{
char * str=NULL;
str=a();
printf(str);
}
输出的结果为什么不是hello world?
char * a(void)
{
char p[]="hello world";
return p;
}
void main(void)
{
char * str=NULL;
str=a();
printf(str);
}
输出的结果为什么不是hello world?
static char p[]="hello world";
函数结束就被销毁了,呵呵
函数结束就被销毁了.
你加一个 static 试验一下。
static char p[]="hello world";