Answer:
Following are the code in the C programming Language.
//define function
void duplicate(char*argv, char**result) {
//set and initialize the variable to 0
int c = 0;
//set and initialize the char type pointer variable
char** t = argv;
//set the while loop
while(t){
//increment by 1
c++;
//increment by 1
t++;
}
//set malloc function in the pointer variable
result= malloc(sizeof(char)*(c+1));
//set the for loop
for(int i = 0; i < c; i++) {
//set malloc function in the pointer
(*result)[i] = malloc(strlen(argv[i])+1);
//copy the character from memory
memcpy(argv[i], (*result)[i], strlen(argv[i])+1) ;
}
//initialize null in the pointer
(*result)[i] = NULL;
}
Explanation:
In the following code, we define function "duplicate()" and pass two character type pointer arguments "*argv" and "**result" and inside the function.