是C中的大小; INT" 2字节或4字节?

编程入门 行业动态 更新时间:2024-10-12 20:20:39
本文介绍了是C中的大小; INT" 2字节或4字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请问C中的整型变量占用2个字节或4个字节?哪些因素,这取决于?

Does an Integer variable in C occupy 2 bytes or 4 bytes? What are the factors that it depends on?

大多数的教科书都说整数变量占用2个字节。但是,当我运行一个程序打印整数数组的连续地址就显示4的区别。

Most of the textbooks say integer variables occupy 2 bytes. But when I run a program printing the successive addresses of an array of integers it shows the difference of 4.

推荐答案

我知道这是等于的sizeof(INT)。的大小 INT 真的是编译器相关的。早在一天,当处理器是16位,一个 INT 为2个字节。现今,这是最常见的是32位的系统上的4个字节或64比特的系统的8个字节。

I know it's equal to sizeof(int). The size of an int is really compiler dependent. Back in the day, when processors were 16 bit, an int was 2 bytes. Nowadays, it's most often 4 bytes on a 32 bits system or 8 bytes on 64 bits system.

不过,使用的sizeof(INT),是为执行该程序的特定系统的整数大小的最佳方式。

Still, using sizeof(int) is the best way to get the size of an integer for the specific system the program is executed on.

更多推荐

是C中的大小; INT" 2字节或4字节?

本文发布于:2023-11-25 10:33:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629409.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字节   大小   INT   QUOT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!