信息发布→ 登录 注册 退出

解决不用sizeof求出int大小的方法

发布时间:2026-01-11

点击量:

代码如下所示:
复制代码 代码如下:
#include <stdio.h> 
int main(int argc, char *argv[]) 

    int a[2]; 
    unsigned int add1 = &a[0]; 
    unsigned int add2 = &a[1]; 
    printf("The address of a[0] is %u/n",add1); 
    printf("The address of a[1] is %u/n",add2); 
    printf("The size of int is %u/n", add2 - add1); 
}

输出结果是:
The address of a[0] is 3218821936
The address of a[1] is 3218821940
The size of int is 4

在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!