Link to home
Start Free TrialLog in
Avatar of Roxanne_Hayling
Roxanne_Hayling

asked on

C++ Program for copying files

I have an exam  and need a simple progam to copy from one file to another in c++ program
I also have to open and close the file
Avatar of cookre
cookre
Flag of United States of America image

Sorry, we can't do homework, but if you can post a first stab at the code, we can help out..
Just like you have to open a book to read or write in it, and you close it when you're done, you do the same thing with files.

To push the metaphor even further, if you're hand copying a book, you might copy one line at a time.

Have you tried surfing for sample code?
Avatar of abhinaysinha
abhinaysinha

The process is to open the file in binary mode, read it an write it the target. I guess I shouldn't send you the code
ASKER CERTIFIED SOLUTION
Avatar of death_befo_dishonor
death_befo_dishonor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Uh, folks, I seriously doubt that this elementary assignment has anything to do with binary files.
Its true that it does not directly deal with binary files, but opening the file in a binary mode will give a more generalised approach
One byte at once is easy to implement but it is slooooow. If you read blocks (I use 1024 bytes) the transfer rate will fly up into the sky!!!
You can also use "Scripting.FileSystemObject" object for copying file.
FileSystemObject  can be used for all file operations. no need of binary file copy.

find out if you can use this object  in C++. Check for any such libraries

death_befo_dishonor should earn the points