#include <stdio.h>
/*
1.代码区(text segment):存放CPU执行的机器指令,该区域只读,通常代码区共享.如果代码被频繁的执行,只需要在内存中有一份代码区.
2.数据区(data segment),明确初始化的全局变量,静态变a量(全局静态变量和局部静态变量)和常量数据(字符常量)
3.BSS区(uninitialized data segment),存放全局和静态变量未初始化的变量或者初始化为0.
4.栈区(statck):由编译器自动分配,释放,存放函数的参数直,局部变量
5.堆区(heap):用于动态内存分配.堆区一般在.bss和栈区之间,一般是由程序员去申请和分配.
*/
int a1; //.BSS
int a2 = 0; //.BSS
int a3 = 10; //.data
void test(int a, int b, int c, int d, int e)
{
printf("%s:a = %p\n", __func__, &a);
printf("%s:b = %p\n", __func__, &b);
printf("%s:c = %p\n", __func__, &c);
printf("%s:d = %p\n", __func__, &d);
printf("%s:e = %p\n", __func__, &e);
printf("@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf("%d, %d, %d, %d, %d\n", a, b, c, d, e);
}
int main()
{
static int b1; //.BSS
static int b2 = 0; //.BSS
static int b3 = 10; //.data
int c1 , c2 = 0, c3 = 10;
int i = 10;
printf("a1 = %p\n", &a1);
printf("a2 = %p\n", &a2);
printf("a3 = %p\n", &a3);
printf("b1 = %p\n", &b1);
printf("b2= %p\n", &b2);
printf("b3 = %p\n", &b3);
printf("c1 = %p\n", &c1);
printf("c2 = %p\n", &c2);
printf("c3 = %p\n", &c3);
test(i++, ++i, i, i++, ++i);
// test(1,2,3,4,5);
return 0;
}
转载于:https://www.cnblogs.com/ltlly/p/4684455.html