#include <stdio.h> #include <tchar.h> #include <malloc.h> int g_i = 100; int g_j = 200; int g_k,g_h; void main(int argc,TCHAR*argv[]) { const int MAXN = 100; int *p = (int*)malloc(MAXN * sizeof(int)); static int s_i = 10; static int s_j = 20; static int s_k; static int s_h; int i = 10; int j = 20; int k = 40; int f,h; char *pstr1 = "MoreWindows123456789"; char *pstr2 = "MoreWindows123456789"; char *pstr3 = "Hello"; printf("堆中数据地址: 0x%08x\n",p); putchar('\n'); printf("栈中数据地址(有初值): 0x%08x = %d \n",&i,i); printf("栈中数据地址(有初值): 0x%08x = %d \n",&j,j); printf("栈中数据地址(有初值): 0x%08x = %d \n",&k,k); printf("栈中数据地址(无初值): 0x%08x = %d \n",&f,f); printf("栈中数据地址(无初值): 0x%08x = %d \n",&h,h); putchar('\n'); printf("静态数据地址(有初值): 0x%08x = %d \n",&s_i,s_i); printf("静态数据地址(有初值): 0x%08x = %d \n",&s_j,s_j); printf("静态数据地址(无初值): 0x%08x = %d \n",&s_k,s_k); printf("静态数据地址(无初值): 0x%08x = %d \n",&s_h,s_h); putchar('\n'); printf("全局数据地址(有初值): 0x%08x = %d \n",&g_i,g_i); printf("全局数据地址(有初值): 0x%08x = %d \n",&g_j,g_j); printf("全局数据地址(无初值): 0x%08x = %d \n",&g_k,g_k); printf("全局数据地址(无初值): 0x%08x = %d \n",&g_h,g_h); putchar('\n'); printf("字符串常量数据地址 0x%08x 指向 0x%08x 的内容是 -%s \n",&pstr1,pstr1,pstr1); printf("字符串常量数据地址 0x%08x 指向 0x%08x 的内容是 -%s \n",&pstr2,pstr2,pstr2); printf("字符串常量数据地址 0x%08x 指向 0x%08x 的内容是 -%s \n",&pstr3,pstr3,pstr3); free(p); }