现在的位置: 首页 > 综合 > 正文

数据代码地址分布

2013年08月21日 ⁄ 综合 ⁄ 共 413字 ⁄ 字号 评论关闭

   大家可以运行这段代码,我相信足以让你明白

 

#include <stdio.h>
#include <stdlib.h>

const int i = 10;  //文本常量区

int  j = 10;  //初始化全局区

int n;  // 未初始化全局区

char *p = "test"; // "test"在文本常量区,指针自身在初始化全局区

int main()
{
 char *p1 = "Hello"; // "Hello"在文本常量区,指针自身在栈里
 const int m = 10; // m在栈里
 
 printf("二进制文件区域:%0x /n", main);
 printf("文本常量区:%0x %0x %0x /n", &i, p, p1);
 printf("初始化全局区:%0x %0x /n", &j, &p);
 printf("未初始化全局区:%0x /n", &n);
 printf("栈:%0x %0x /n", &p1, &m);
 
 return 0;
}

终于把编码问题搞定了,推荐slickedit

抱歉!评论已关闭.