In my C++ program I have to use fork() a number of times that the program takes as an argument in the command line,let's say I have to use fork() k times.
How am I supposed to refer to the children processes?
I mean when I have only one child I do:
Now that I have k children ,for the fork I do:
but what about the if statement?
Add your if statement as part of the for loop, or visa versa depending on what or the order your trying to test, making sure it is in same scope. You can do this with proper usage of braces.