手机
当前位置:查字典教程网 >编程开发 >C语言 >解决不用sizeof求出int大小的方法
解决不用sizeof求出int大小的方法
摘要:代码如下所示:复制代码代码如下:#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

【解决不用sizeof求出int大小的方法】相关文章:

解析如何在C语言中调用shell命令的实现方法

解析Linux下的时间函数:设置以及获取时间的方法

c/c++输出重定向的方法

C语言 解决不用+、-、×、÷数字运算符做加法的实现方法

解决C++中事件不响应的方法详解

关于STL中list容器的一些总结

C/C++指针和取地址的方法

判断机器大小端的两种实现方法

探讨:将两个链表非降序合并为一个链表并依然有序的实现方法

数组中求第K大数的实现方法

精品推荐
分类导航