Write a program that reads a text file character by characterand makes a copy th
ID: 3610523 • Letter: W
Question
Write a program that reads a text file character by characterand makes a copy the file in other text file with the namename_backup.txt Modify the code of the previous exercise in such a way thatthe user can write with the keyboard the full path and name of thefile to be copied, as well as the full path and name of the copy(file backup). In C++ Write a program that reads a text file character by characterand makes a copy the file in other text file with the namename_backup.txt Modify the code of the previous exercise in such a way thatthe user can write with the keyboard the full path and name of thefile to be copied, as well as the full path and name of the copy(file backup). In C++Explanation / Answer
#include#includeusing namespace std;int main(){char ch;char file[100];char file_bck[100];char *temp,*ptr;int count=0;coutfile;if((ptr=strstr(file,"."))!=NULL){for(temp=file;*temp!='';temp++){if(temp == ptr){strcpy(&file_bck[count],"_backup");count = count+ strlen("_backup");}file_bck[count++] = *temp;}file_bck[count]='';}else{strcpy(file_bck,file);strcat(file_bck,"_backup");}ifstream myfile (file);if (myfile.is_open()){ofstream myofile (file_bck);if (myofile.is_open()){}else {coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.