word是2个字节长没错吧?

来源:互联网  时间:2016/9/6 14:44:53

关于网友提出的“ word是2个字节长没错吧?”问题疑问,本网通过在网上对“ word是2个字节长没错吧?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: word是2个字节长没错吧?
描述:

在C++ Primer 英文第4版
P35页有一句话:
Although the exact sizes can vary from one machine to another, we ususally refer to a chunk of 8 bits as a "byte" and 32bits, or 4 bytes, as a "word".
还有P34页:
Typically, shorts are represented in half a machine word, ints in a machine word,
为什么说word是4个字节呢?
在windef.h定义如下:
typedef unsigned long       DWORD;
typedef unsigned short      WORD;
是不是primer的word不作WORD理解?


解决方案1:

字长是根据机器来说的,32位机的字长就是32位,64位机的字长就是64位。跟你说的word、byte不同。

解决方案2:

a machine word not "word"
LZ理解有误啊
shorts are represented in half a machine word, ints in a machine word
这里说的是short类型占半字(2byte), int类型占一字(4byte)
表述word类型的时候通常是"word"

解决方案3:

注意Typically
Windows 9x/Nt最开始需要和16位Windows代码级兼容,所以不能随便把WORD长度变了

上一篇tcp怎样链接多个socket?
下一篇类似WINRAR的文件拖放如何实现
明星图片
相关文章
《 word是2个字节长没错吧?》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)