generate functionMon, 02 Jan 2023

, create a program that receives a folder path as its arguments when executed i.e (./filename filepath) and copies each file in the folder to another folder created by your program. Create a separate child process for each file

int main(int argc, char* argv[]) { char *source; char *destination; pid_t pid; if(argc == 3){ source = argv[1]; destination = argv[2]; } else { printf("Enter the source and destination address\n"); scanf("%s %s", source, destination); } pid = fork(); if(pid == 0) { execl("/bin/cp", "cp", source, destination, NULL); exit(0); } else { wait(NULL); printf("File copied successfully\n"); } return 0; }

Questions about programming?Chat with your personal AI assistant