将单个位写入文件 [英] Writing single bits to a file

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

问题描述

我正在开发一个压缩程序。有没有办法以位的形式写一个

数据到文件,比如写0位然后写1位然后

位1等等....

I am developing a compression program. Is there any way to write a
data to file in the form of bits, like write bit 0 then bit 1 and then
bit 1 and so on ....

推荐答案

好吧,如果我只有19个字节要写,那意味着2个字符和3个

比特!
Well, what if I have just 19 bytes to write that means 2 chars and 3
bits!


10月26日下午3:42,riva< ra.ravi .... @ gmail.comwrote:
On Oct 26, 3:42 pm, riva <ra.ravi....@gmail.comwrote:

好​​吧,如果我只有19个字节来写,那意味着2个字符和3个
Well, what if I have just 19 bytes to write that means 2 chars and 3
bits!



啊,不。这意味着19个字符和0位。但是你的意思是什么?我

在我的电脑上创建一个1字节的文件,它在我的硬盘上需要4,096字节(另外还有文件名,创建日期等空间)

Ah, no. That means 19 chars and 0 bits. But what''s your point? I
create a 1 byte file on my computer and it take 4,096 bytes on my hard
disk (plus room for file name, creation date, etc.)




(当您回复Usenet帖子时,请引用足够的

上下文以使您的回复有意义作为一个独立的

消息。人们不会总是从一开始就按顺序进行讨论

,以及第一次遇到
$ b的人$ b线程就像 - 好吧,就像你写的那样

以下 - 将很难发现主题

是什么,并且很可能因此,你冒着剥夺自己专业知识的风险。对于那些只是调整的人来说,riva

询问如何将单个位写入流中。) />

riva写道:10/26/07 16:42,:

(When you reply to a Usenet post, please quote enough
context to make your reply meaningful as a stand-alone
message. People don''t always follow a discussion serially
from its start, and someone whose first encounter with a
thread is something like -- well, like what you''ve written
below -- will have a hard time discovering what the topic
is, and are likely to ignore it. Thus, you risk depriving
yourself of their expertise. For those just tuning in, riva
asked how to write individual bits to a stream.)

riva wrote On 10/26/07 16:42,:

好​​吧,如果我只有19个字节可写这意味着2个字符和3个b $ b位!
Well, what if I have just 19 bytes to write that means 2 chars and 3
bits!



我认为你的意思是位,不是字节。这就是为什么

我写的

I think you mean "bits," not "bytes." And that''s why
I wrote


> [...]在<结束时,您可能需要提供一些额外的位来填充最后一个字符。
>[...] At the
end, you may need to provide a few extra bits to fill
up the final character.



....在你没有引用的部分。我的句子中有什么东西让你感到困惑吗?


-
Er ********* @ sun.com


这篇关于将单个位写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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