HomeworksFile Systems
FS-2: Copy a file
Learn to copy files in C++ on Linux with proper error handling. Overwrite destination files effortlessly. Perfect for System Programming beginners.
Requirements
- Write a C++ program simple-copy accepting two command line arguments representing source file path and destination file path.
- Implement proper error handling to account if not all arguments are passed or if one of arguments is not a valid one.
- Copy the content of the source file into a destination file. If destination file already exists, it should be overwritten.
Expected result
The resulting application should be able to build and execute from command line as follows:
make
./simple-copy source-file destination-fileThe final solution should contain a Makefile for the multi-stage build. The Makefile should also contain targets all and clean. It's recommended to have compiler and compiler flags declared as Makefile variables. Alternatively, cmake could also be used instead of make.