You are here:

C++/Question in c++

Advertisement


Question
I am biginner in C++, so please help,My question is

Que:  :  Write a program that emulates the DOS COPY command i.e., it should copy the contents of a character file (such as any CPP file) to another file. Invoke the program with two command line arguments the source file and the destination file like this

C>ocopy srcfile.ext   destfile.ext

In the program check that user has typed the correct number of command line arguments, and that the file specified can be opened. Improve on the DOS TYPE command by having the program signal an error if destination file already exist. This will prevent inadvertently writing over a valuable file.  

Answer
1. copy contents: File IO: See http://www.cplusplus.com/doc/tutorial/files.html For copying non-text files (like .exe etc) use binary mode.
2. command line arguments: See http://malun1.mala.bc.ca:8080/~wesselsd/csci161/notes/args.html and http://www.cprogramming.com/tutorial/lesson14.html
3. File exists or not: http://www.computing.net/programming/wwwboard/forum/11411.html

Hope this helps.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Amit Kumar

Expertise

I can answer Cplusplus language and library questions, including STL, ACE, Boost. I have a good background in Mathematics.

Experience

Programming in CPP for about 8 years. Industry experience of 4 years.

Education/Credentials
Bachelors and Masters in Computer Science from Indian Institute of Technology Delhi.

©2016 About.com. All rights reserved.