hi,
C++ uses ifstream and ofstream to read and write text files. What if I want to read the binary values of a zip file, and write that back out to another file ,thus creating another copy. How would I go about in doing that?
Is it even possible? thankx.
The fstream classes take an optional parameter to specify a mode to open a file in. One of these is ios::binary. That will allow you to read and write binary files.
These classes also have read and write member functions that do low-level, non-formatted I/O, which is probably what you want to use. Look in any C++ library reference for the details.
Since you picked this forum, I assume you're working on Windows. If that's true, the above is relevant. If you're working on a Unix-like system, though, there's no difference between opening a binary file and a text file.
hi,
thanks for your suggestions. I have another question,
after I get the binary values of the zip file and create a new file using that, will the new file that will be created be useable? thankx again.
The copy command you're talking about, is it using a dos command to copy? Id rather learn the binary way.
Anyway, as im typing this, Im still looking for answers.
I have a feeling this will take days, and I wont rest until I squeeze it out of you guys and gals!
If anyone has ever done this before, could you please confirm this for me. I havent found a solution to confirm this yet.
My Question,
C++ uses the ifstream and ofstream to read and write text files. To my understanding, C++ can read in binary mode also. Suppose I use C++ to read the binary value of any file, for example, a zip file in this case. Then take the values that it read and create a new file. Now, if I try to unzip the new file, will it work? Ultimately, will it be identical to the original file?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.