Question
Hi, I need help with this c++ program: File Copy The program asks the user to enter a name of a file; and then, creates
Hi, I need help with this c++ program:
File Copy
The program asks the user to enter a name of a file; and then, creates a copy of the file. This program defines the following function:
void copyFile(char* filename)
This function tries to open the file, filename, for reading. If the file does not open, display the message File cannot open and terminate the function.Otherwise, open a new file for writing, then copy the content of the original file to the new file.
The name of the new file should be _cp_ appended to the beginning of the name of the original file.
For example, if the original file is named sample.txt, then the new file name would be _cp_sample.txt.
Use the strcat() function to create the new file.
Reminder: Whenever you open a file, you must remember to close it.
In the main, Create a char array.
Prompt the user to enter a file name.
Store the input of the user in the char array.
Call the copyFile() function with the char array as the argument.
The program should begin as follows:
#include
#include
#include
using namespace std;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started