什么是“字节"?在 C/C++ 中 [英] What is a "byte" in C / C++
本文介绍了什么是“字节"?在 C/C++ 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,这里是 fread 的参考:
For example, here's a reference for fread:
size_t fread ( void * ptr, size_t size, size_t count, FILE * stream );
读取一个计数元素数组,每个元素的大小为大小字节"...那么有多少 BITS 会读取一个 fread(&x, 1, 1, stream)
?八位还是CHAR_BIT
?
Reads an array of count elements, each one with a size of "size bytes"...
So how many BITS will read an fread(&x, 1, 1, stream)
? Eight or CHAR_BIT
?
推荐答案
C99, §3.6:
字节
足够大的可寻址数据存储单元以容纳执行环境的基本字符集的任何成员
addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
和§5.2.4.2.1:
and §5.2.4.2.1:
CHAR_BIT — 不是位域(字节)的最小对象的位数
CHAR_BIT — number of bits for smallest object that is not a bit-field (byte)
因此,一个字节"包含 CHAR_BIT
位.
Thus, a "byte" contains CHAR_BIT
bits.
这篇关于什么是“字节"?在 C/C++ 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文