Question: Part 4 : write code in c + + and submit it to the autograder This is a code mimic the linux cp command. Here

Part 4: write code in c++ and submit it to the autograder This is a code mimic the linux cp command. Here are the requirements.1. This program works by first prompting the user for the name of the source file and destinationfile. It shall include all necessary error checking, including ensuring that the source file exists.The main function should return 0 upon successful execution and return 1 upon error condition.Hint: int open(const char *pathname, int flags, mode_t mode);2. The program needs to pass several test cases set in the autograder.
It is a common practice to test the code using shell script in software engineering. We are notrequired to write test cases. Instead, students can submit the code to run the test inAutoGrader.For learning purposes, I attach an example for your reference:Test case example#!/bin/bashecho "Hi, this is the source file to be used" > source.txtecho "This is an existing file to be used" > existing.txtecho "Test case 1: destination file does not exist"if ./mycopy source.txt source.txt.bak;thenecho "Using diff command to see if two files are same"diff source.txt source.txt.bakelseecho "Something went wrong";fiecho "Test case 2: destination file already exist"if ./mycopy source.txt existing.txt;thenecho "Using diff command to see if two files are same"diff source.txt existing.txtelseecho "something went wrong"fiecho "Test case 3: source file does not exist"if mycopy no_existing_file destination_file;thenecho "Using diff to compare two files"diff no_existing_file destination_fileelseecho "Something went wrong"fiAfter editing the above file, say, saving it as testScript, use the following command to make thefile executable by all: chmod +x testScriptThen you will be able to type the following command line to execute the commands in the script(in order to test your program): ./testScript

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!