解决不用sizeof求出int大小的方法
来源:本站原创|时间:2022-11-25|栏目:C语言|
代码如下所示:
复制代码 代码如下:
#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
您可能感兴趣的文章
- 01-10c语言求1+2+...+n的解决方法
- 01-10求子数组最大和的解决方法详解
- 01-10c语言 跳台阶问题的解决方法
- 01-10用贪心法求解背包问题的解决方法
- 01-10C语言 解决不用+、-、&#215;、&#247;数字运算符做加法
- 01-10fatal error LNK1104: 无法打开文件“libc.lib”的解决方法
- 01-10深入sizeof的使用详解
- 01-10Linux下semop等待信号时出现Interrupted System Call错误(EINTR)解决方法
- 01-10判断整数序列是否为二元查找树的后序遍历结果的解决方法
- 01-10解析sizeof, strlen, 指针以及数组作为函数参数的应用