Simple program to copy one file to another.

Create a simple program to copy one file to another.
Your program should do the following:

(a) Accept two command line parameters — the source and destination filenames — checking whether they are correctly specified.
(b) Open the source file for reading, and the destination file for writing.
(c) Check that they both opened correctly, and report an error if appropriate.
(d) Read the source file character-by-character, and write each character to the destination file.
(e) Stop when the end of the source file is reached.
 

Note: The final read operation will fail — that's when you detect the end of the file. Make sure not to write an extra bogus character to the destination file.

(f) Close both files when complete.

Solved
Programming in C,C++ 1 Answer Anonymous(s) Post