有可能小于1字节写入文件 [英] It is possible to write less than 1 byte to a file
问题描述
据我所知在C最小单位是一个字节
。哪里该约束从何而来? CPU?
As far as I know the smallest unit in C is a byte
. Where does this constraint comes from? CPU?
例如,我怎么能写轻咬
或一个位
到一个文件?
For example, how can I write a nibble
or a single bit
to a file?
推荐答案
不,你不能......文件以字节为单位组织的,它是最小的一块数据可以保存。
no, you can't... files are organized in bytes, it's the smallest piece of data you can save.
和,事实上,这1个字节将占据超过1个字节的空间,在一般。根据不同的操作系统,系统文件类型,等等,你都保存为文件将使用至少一个块。和块的大小根据你使用的文件系统的不同而不同。然后,这个1位将被写为1 - 字节,能够占据尽可能多的磁盘4kB的
And, actually, that 1 byte will occupy more than 1 byte of space, in general. Depending on the OS, the system file type, etc, everything you save as a file will use at least one block. And the block's size varies according to the file system you're using. Then, this 1-bit will be written as 1 - byte and can occupy as much as 4kB of your disk.
在维基你可以阅读一些有关字节是最小的数据单位在多台计算机上。
In wikipedia you can read something about the byte being the smallest data unit in many computers.
这篇关于有可能小于1字节写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!