Visual c ++请帮忙......? [英] Visual c++please help...?
问题描述
如何读取二进制文件并进行更改。
例如:
我们计算机中的每个数据/文件都有二进制源,只有0和1。 br />
我有一个二进制文件,其中主要使用
How to read binary file and change it.
For example:
Every data/file in our computer have its binary source which is only 0s and 1s.
I have a binary file in which
01000100
。我想改变
01000100
与
01100100
如何在c ++中执行此操作?
How can i do that in c++?
推荐答案
如果您需要更改文件的内容(即覆盖它)然后你必须:
If you need to change the content of a file (that is overwrite it) then you have to:
- 将文件内容读入内存。
- 修改内存内容。
- 将修改后的内存内容写回原始文件。
您可以使用 C ++
fstream
读取/写入二进制文件,例如参见带文件的输入/输出 [ ^ ]代码示例。
您也可以使用 C
-like函数fopen,fwrite,fread做同样的事情。例如,请参见 fopen [ ^ ] fwrite [ ^ ],fread [ ^ ]。
You may use the C++
fstream
to read/write a binary file, see, for instance Input/Output with files[^] for code samples.
You may as well use the C
-like functions fopen,fwrite,fread for doing the same. See, for instance fopen[^] fwrite[^], fread[^].
这篇关于Visual c ++请帮忙......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!