working with process, fork command
<p>im writing a simple code, making new process with fork, and then I want to see who is the child process and who is the father process.
As I know, the return value of fork to the child pc is 0 and to the father process is the pid number or child process.
somehow in both the child and the father I get 0.
can someone explain to me what is wrong with this code? 
thanks.</p>

<p>the code is : </p>

<pre><code>#include &lt;sys/wait.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;string.h&gt;

void main()
{
    pid_t childpid;
    int status,i;

    if(childpid = fork() == -1){
        perror("fork err");
        exit(1);
    }
    if(childpid == 0){
        printf("child process, pid number is %d and returned value from fork is %d\n",getpid(),childpid);
    }
    else{
        printf("father process, pid number is %d and returned value from fork is %d\n",getpid(),childpid);
    }



}
</code></pre>