关于指针占内存情况

指针的长度就是机器的地址长度,绝大部分情况下跟字长也相符。例如32位机就是32位的指针出长度,换算一下就是4个字节,64位机器上就是8字节,当然也需要CPU,操作系统和编译器的配合才能得到准确的值。就像32位机器上还可以用TC这种16位的编译器,32位的windows可以模拟16位dos环境,32位的x86也可以兼容16位的8086,所以在win32下用TC编译程序就是16位指针。同理在64位的windows下也可以兼容执行32位程序。
以上

struct all
{
    struct all *next;
    int a,b,c;
}rec;
int main(void)
{
 int *a=NULL;
    printf("The size of rec is %d,/n"
              "and the size of int type is %d/n"
                 "and the size of  all.next is %d/n "
        "and the size of a pointer is %d/n",
                     sizeof(rec),sizeof(int),sizeof(a),sizeof(rec));
   
    getchar();
    return 0;
}

 

输出结果为:

The size of rec is 16,
and the size of int type is 4
and the size of  all.next is 4
 and the size of a pointer is 16

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值