摘要:
char *fun(void){char *p="hello";return p;} int main(void){char *s;s=fun();printf("%s\n",s);}程序运行后有什么问题呢?一般人可能会回答说是内存错误,实际上不是, char *p="hello";分配在常量区,不会立即释放。 如果是如下的程序char *fun(void){char p[]="hello";//注意return p;}int main(void){char *s;s=fun();printf("%s\n",s);}很多人回答说是会出错。而我在运行过程中,却没发现出错。原因如下: 阅读全文
posted @ 2010-12-24 09:56
Likwo
阅读(381)
评论(0)
推荐(0)

浙公网安备 33010602011771号