Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to I/O files in binary(means in 0s and 1s).
I also want to edit these 0s and 1s of files.
I have no idea how to do that... please help me.
Posted
Comments
Alamgirable 20-Feb-13 14:45pm    
OR any body tell me the best place to start working with 0s and 1s.
Richard C Bishop 20-Feb-13 15:32pm    
That is quite comical that you think you would have to define "binary" on a programming site of this magnitude.

You have everything you need with std::ofstream, std::ifstream and std::fstream:
http://www.cplusplus.com/doc/tutorial/files/[^].

I hope you also know bitwise arithmetic and bitwise operators. If not, lean them. Streams give you per-byte access, so you can read a byte, extract individual bits, modify them the way you want and write the whole byte. This is one of the most basic skills all developers are supposed to master.

See, for example: http://www.cplusplus.com/doc/tutorial/operators/[^].

—SA
 
Share this answer
 
Comments
CPallini 20-Feb-13 15:41pm    
5.
Sergey Alexandrovich Kryukov 20-Feb-13 19:13pm    
Thank you, Carlo.
—SA
Maciej Los 20-Feb-13 16:14pm    
Short and to the point! +5!
Sergey Alexandrovich Kryukov 20-Feb-13 19:13pm    
Thank you, Maciej.
—SA
You usually do not directly edit the 1s and 0s.

When wanting to edit a binary file, people use a Hex Editor[^] where you can edit the hexadecimal representation of the binary file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900