?
Solved

C++ Program for copying files

Posted on 2003-11-30
13
Medium Priority
?
423 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Introduction to Processes

650 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