C语言常见变量在内存的存储区域

局部变量除了static修饰的放在静态区,其余全部栈区(包括const修饰的常量、字符串常量)。全局变量和static修饰的全局变量放在静态区,const修饰的放在常量池,字符串常量放在静态区。

char q[] = "where is the address";
static int x= 9;
int y =6;
const int z =1;
int main(int argc, char const *argv[])
{
    const char m[] = "address";
    char s[] = "address in";
    static int a= 80;
    int b =0;
    const int c =3;
    printf("顺序打印地址\n");
    printf("%p\n",q);
    printf("%p\n",&x);
    printf("%p\n",&y);
    printf("%p\n",&z);
    printf("\n");
    printf("%p\n",m);
    printf("%p\n",s);
    printf("%p\n",&a);
    printf("%p\n",&b);
    printf("%p\n",&c);
    
    return 0;
}

打印结果:

顺序打印地址
0x5e19e2e09010
0x5e19e2e09028
0x5e19e2e0902c
0x5e19e2e07004

0x7fffb73f9cd5
0x7fffb73f9cdd
0x5e19e2e09030
0x7fffb73f9ccc
0x7fffb73f9cd0

若有不同欢迎指正!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值