Question: You are asked to write file copy program in C++ . The program will take two arguments. The first argument will be the name of

You are asked to write file copy program in C++. The program will take two arguments. The first argument will be the name of the file to copy from; where as, the second argument will be the name of the file to copy to. Your program is a simplified version of the cp command in linux.

Example Usage

The following command will copy text file in.txt to out.txt. $ ./file-copy in.txt out.txt Similarly, the following command will copy image in.jpg to out.jpg $ ./file-copy in.jpg out.jpg

And so on.

Caveats

Please adhere to the following conditions:

Your program file-copy should be able to handle file of any type and any size.

You may assume that memory available to your program is less than the size of the files that need copying.

This suggests that you cannot load the entire file in the memory. Assume that the largest buffer size

that you are allowed to allocate is 1000 bytes.

You are may use functions available in fstream and iostream

You may not any other advanced functions. E.g., you may not invoke the system cp command to do the task

for you.

Use Makefile such that we are able to build your program using make all command.

You can use the following file-copy.cpp skeleton to write your program. #include

#include

using namespace std;

int main(int argc, char** argv) { 
 // argv[0] is the name of the program // argv[1] is the name of the input file  

1

// argv[2] is the name of the output file // max character buffer size allowed is 1000  

// TODO

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!