#include #include #include #include // declare the function // void copy_args(int argc, char** argv_out, char** argv_in); int main(int argc, char** argv) { char** argv_2; copy_args(argc, argv_2, argv); fprintf(stdout, "the number of arguments was %ld\n", argc); for (long i = 0; i < argc; i++) { fprintf(stdout, "%ld: in:<%s> out:<%s>\n", i, argv[i], argv_2[i]); } } // add your implementation here // void copy_args(int argc, char** argv_out, char** argv_in) { // Create temporary pointer to array to hold the argument count // char** new_arg = new char*[argc]; // Loop over number of args and store the length of char string in each argument plus a null char to each index // for (int i = 0; i < argc; i++) { new_arg[i] = new char[strlen(argv_in[i])+1]; strcpy(new_arg[i], argv_in[i]); } // Point to argv_out and set it equivalent to the address of the pointer array for new_arg // *argv_out = **&new_arg; // Free memory created with new_arg to ensure no memory leaks // delete [] new_arg; }