首页 > 代码库 > 内存分区

内存分区

 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 }