Solved

C++ Program for copying files

Posted on 2003-11-30
13
392 Views
Last Modified: 2010-04-17
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
0
Comment
Question by:Roxanne_Hayling
  • 4
  • 2
  • 2
  • +2
13 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 9847070
Sorry, we can't do homework, but if you can post a first stab at the code, we can help out..
0
 
LVL 22

Expert Comment

by:cookre
ID: 9847092
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?
0
 
LVL 22

Expert Comment

by:cookre
ID: 9847127
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Expert Comment

by:abhinaysinha
ID: 9852228
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
0
 

Accepted Solution

by:
death_befo_dishonor earned 125 total points
ID: 9854992
i wont send u the source code but here is a tip that might be useful:

open the source file*
open the destination file*

read 1 byte from the source file
write it to the destination file

when there r no bytes left in the source file then close both files... and u done :)

*these must be opened by the binary reader/writer

this method of reading 1 byte at a time is BY FAR the fastest and best way to go about it... it's fast because your program does not need any extra memory except 1 byte

hope this helps... suma
0
 
LVL 22

Expert Comment

by:cookre
ID: 9855113
Uh, folks, I seriously doubt that this elementary assignment has anything to do with binary files.
0
 
LVL 1

Expert Comment

by:abhinaysinha
ID: 9856055
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
0
 
LVL 4

Expert Comment

by:void_main
ID: 9856640
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!!!
0
 

Expert Comment

by:nakhab
ID: 9895403
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

0
 
LVL 4

Expert Comment

by:void_main
ID: 10319744
death_befo_dishonor should earn the points
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question