Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read exe? 1

Status
Not open for further replies.

Sidro

MIS
Sep 28, 2002
197
US
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.
 
why don't you try to see by yourself?

Ion Filipski
1c.bmp
 
Here's a hint:

The copy command works exactly the way you intend to write your program.
 
Hi Chip!
Lol!!!

Lend me some sugar, I am your neighbor!

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?

Thankx in advance.
 
>Ultimately, will it be identical to the original file?

Why wouldn't it be?

I've got a feeling you've got a long way to go.
Forums like this isn't a very effective way to learn about all of the basics of computing.

Give a hoot - read a book!


/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
hi all,

Wow! I read my cs book and got it to work in 5 minutes!
Big thanks to chipperMDW for pointing me to the right way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top