Question: Write a C program that takes two arguments from the command line: one filename and one number of items. Your program must check if a
Write a C program that takes two arguments from the command line: one filename and one number of items. Your program must check if a correct number of arguments are supplied and terminate if not. Your program must create three child processes in the following order: the first-child process creates the mentioned file and fills it with the specified number of random integers (0-1000), one number per line. The second child process executes the sort command to sort the numbers in this file on the screen. The third child process must find the minimum and maximum numbers in this file. Between each child process, parents must wait for the termination of the former process to create the new process.
Sample Run $ ./question1 nums.txt 15
[PARENT] Creating first process...
[CHILD1] Creating nums.txt with 15 integers...
[PARENT] Creating second process...
[CHILD2] Executing sort command... 56 133 147 . . .
[PARENT] Executing third process...
[CHILD3] Min: 56, max: 839
[PARENT]
Done.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
