Amol Mohite wrote:

> In gcc,
> 
> if i = 2;
> then j = i++ + ++i;
> 
>       what is the value of j.

        i++ == 2
        ++i == 3
=>      j   == 5

> what is the calling sequence in this case ? ++i first or i++ first ?

++i; i++ will increment i after the expression has been evaluated.

> why does fork have to return a value of zero to the child process ?

Because it does. fork() has to indicate whether the processes is the
parent or the child. It also has to return the child's pid to the
parent (there isn't any other way for the parent to obtain this
information). The child can just use getppid() to find the pid of its
parent.

> why not -5 or -6 ?

What would a negative return value signify? (currently a negative
result signifies an error, which is the standard convention for
functions which normally return a nonnegative integer when
successful).

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to