代码一: #include <stdio.h> char *fun(void) { // char str[] = "hello world !/n" char *str = "hello world !/n"; return str; } int main(int argc,char *argv[]) { char *a = fun(); printf("%s",a); return 0; } 此函数才能正常运行 不然 如果把注释去掉 注释其下一行 编译就出警告 warning: function returns address of local variable 不能正常运行