#include <stdio.h>
#include <Windows.h>
char *test1(){
char str[] = "HelloWorld!"; //函数运行完,分配的内存被释放
return str;
}
char *test2(){
char *str = "HelloWorld!"; //运行完不释放
return str;
}
char *test3(){
static char str[] = "HelloWorld!"; //静态分配,函数运行完不释放
return str;
}
int main(int argc,char *argv[]){
printf("%s",test1());
printf("%s",test2());
printf("%s",test3());
system("pause");
return 0;
}