[求助]关于指针函数的问题
char *GetMemory(void){
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf("%s",str);
}
请问运行Test 函数会有什么样的结果?
2006-10-12 16:43
2006-10-12 16:50
2006-10-12 16:51
p是局部变量
2006-10-12 16:53
2006-10-21 21:27

2006-10-21 22:52
2006-10-22 13:55
这样也可:
#include<stdio.h>
char p[] = "hello world";
char *GetMemory(void)
{
//char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf("%s",str);
}
int main()
{
Test();
return 0;
}
2006-10-22 14:06
2006-10-22 14:12