什么是C中的“短”的数据类型? [英] What is the 'short' data type in C?

查看:288
本文介绍了什么是C中的“短”的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的函数:

void AddWordData(FILE* dataFile, short word, int* dc)
{
    fprintf(dataFile, "%06o\n", word);
    ++(*dc);
} 

功能越来越短的类型。
我没有在网上搜索一些,但只发现了短整型。
这是什么时候的函数越来越短型意思?
什么数据类型是什么呢?

the function is getting a short type. I did some search in the web but found only short int. what does it mean when a function is getting a short type? what datatype is it?

推荐答案

是短期的短整型。它们是同义的。 短整型符号短签订短整型都是相同的数据类型。到底有多少位都在依赖于编译器和系统,但它需要有的至少有16位的:

short is short for short int. They are synonymous. short, short int, signed short, and signed short int are all the same data-type. Exactly how many bits are in a short depends on the compiler and the system, but it is required to have at least 16 bits:

任何符合标准的编译器也必须尊重相对于数值的任何具体类型可以接受的范围内的下列限制。注意,这些是下限:一个实现可以自由地超过任何或所有这些。还需要注意的是对于一个char最小范围是依赖于一个char是否被认为是带符号。 ...短整型:-32767至+32767

Any compiler conforming to the Standard must also respect the following limits with respect to the range of values any particular type may accept. Note that these are lower limits: an implementation is free to exceed any or all of these. Note also that the minimum range for a char is dependent on whether or not a char is considered to be signed or unsigned. ... short int: -32767 to +32767 .

更多来自维基百科

整数类型的实际大小由执行而异。的唯一保证的是,长长不大于长,这是不大于int,它不小于短小小小。而且,INT应该是整数类型,目标处理器可与最有效的工作。这允许极大的灵活性:例如,所有类型可以是64位。然而,只有几个不同的整数宽度方案(数据模型)是受欢迎,因为数据模型定义不同的程序如何进行通信,一个统一的数据模型,给定的操作系统的应用程序接口中使用。[3]

The actual size of integer types varies by implementation. The only guarantee is that the long long is not smaller than long, which is not smaller than int, which is not smaller than short. Also, int should be the integer type that the target processor is most efficient working with. This allows great flexibility: for example, all types can be 64-bit. However, only several different integer width schemes (data models) are popular and since data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.[3]

在实践中,应当注意的是,炭通常为大小8位,短通常是长度为16位长的大小通常为32位(也无符号字符,符号短和无符号长整数)。例如,对于嵌入的8位PIC单片机这适用于平台等不同的20世纪90年代Sun0S 4的Unix,微软的MSDOS,现代的Linux和Microchip的MCC18真实的。

In practice it should be noted that char is usually 8 bits in size, short is usually 16 bits in size and long is usually 32 bits in size (likewise unsigned char, unsigned short and unsigned long). For example this holds true for platforms as diverse as 1990s Sun0S 4 Unix, Microsoft MSDOS, modern Linux, and Microchip MCC18 for embedded 8 bit PIC microcontrollers.

这篇关于什么是C中的“短”的数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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