Solved

C++ Program for copying files

Posted on 2003-11-30
13
414 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
A short article about problems I had with the new location API and permissions in Marshmallow
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

724 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