Quote:
Originally Posted by
wendy1089
how can i pass the argv value from parent to children
They already have it. They get a copy of it just like they get a copy of everything else.
Quote:
i want first child to read argv first number and second child read second,etc. how can i do that?
Like I've been saying all along,
use the value of i in the child. It gets a copy from the instant the parent called fork(), so child 0 gets 0, child 1 gets 1, child 2 gets 2, child 3 gets 3, child 4 gets for, and so forth.
You may be overthinking this. All your question amounts to is "how do I use an array" and the answer is array[index]. for most purposes argv starts at 1, not 0, so argv[i+1]. Be careful not to exceed the value of argc or you will crash!
Quote:
also how to save pid into array? i tried to use int for it data type, but it seems not successful.
pid_t should work, but int should also work, so I suspect your program failed for other reasons. Not having psychic powers, I can't see from here why it's not working. Post your code!