解决不用sizeof求出int大小的方法_C语言教程-查字典教程网
解决不用sizeof求出int大小的方法
解决不用sizeof求出int大小的方法
发布时间:2016-12-28 来源:查字典编辑
摘要:代码如下所示:复制代码代码如下:#includeintmain(intargc,char*argv[]){inta[2];unsignedi...

代码如下所示:

复制代码 代码如下:

#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

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新C语言学习
    热门C语言学习
    编程开发子分类