?
Solved

C++ Program for copying files

Posted on 2003-11-30
13
Medium Priority
?
416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes
Suggested Courses

800 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