int的大小 [英] size of an int

查看:155
本文介绍了int的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是c的新手,我想知道int或char或float的大小决定了什么参数,我的意思是它仅依赖于编译器还是编译器和OS。或者我们正在使用的所有上述和处理器或RAM的组合


...如果我们使用的是32位处理器且操作系统是16位,那么int的大小将是16 bits?

解决方案

char的大小总是1个字节,C标准保证。字节中的位数取决于平台。

int的大小应该是平台处理最有效的大小(16位处理器上的16位等)但情况并非总是如此。


对于这篇文章,平台应该只是处理器,但编译器也会产生影响。


嗨!

您可以从softwer whit运算符sizeof中获取en变量的大小。这给出了实际变量的大小(以字节为单位)。

使用很简单:

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


当然,参数列表周围有括号:

展开 | 选择 | Wrap | 行号

i am newbie in c ,i want to know on what parameters the size of int or char or float is decided , i mean does it depend on compiler only or "compiler and OS" or combination of all above and processor or RAM we are using

like...If we are using a 32 bit processor and OS is 16 bit , then will the size of int be 16 bits ?

解决方案

The size of a char is always 1 byte, the C standard guarantees that. The number of bits in a byte is platform dependent.

The size of int should be the size that is most efficient for the platform to process (16 bits on a 16 bit processor etc) but that is not always the case.

For this post the platform should be just the processor but the compiler can have an effect too.


Hi!
You can take the size of en variable from softwer whit operator sizeof. This give the size of actual variable in bytes.
use is simple:

Expand|Select|Wrap|Line Numbers


With, of course, parentheses around the argument list:

Expand|Select|Wrap|Line Numbers


这篇关于int的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆