源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2020-01-26 07:34 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:解决不用sizeof求出int大小的方法
代码如下所示:
[u]复制代码[/u] 代码如下:
#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);  }
[b]输出结果是: [/b]The address of a[0] is 3218821936 The address of a[1] is 3218821940 The size of int is 4
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部