内存分区

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 
 4 int k=1;
 5 int main()
 6 {
 7     int i=1;
 8     char *j;
 9     static int m=1;
10     char *n="hello";
11 
12     printf("栈区地址为:0x%x\n",&i);
13 
14     j=(char*)malloc(2);
15     free(j);
16 
17     printf("堆区地址为:0x%x\n",j);
18     printf("全局变量为:0x%x\n",&k);
19     printf("静态变量地址为:0x%x\n",&m);
20     printf("文字常量区地址为:0x%x\n",n);
21     printf("程序区地址为:0x%x\n",&main);
22 
23     return 0;
24 }

 

posted @ 2014-05-22 20:42  王冯学  阅读(120)  评论(0编辑  收藏  举报