title: working of fork in c language
body: <p>Now I have a problem in understanding the working of <code>fork()</code> system call.
  I write a code which is following :</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int a, b;
      b=fork();
  
      printf("\n the value of b = %d",b);
  }
  </code></pre>
  
  <p>The output of  this code is following :</p>
  
  <p>Now I don't understand why the output is like this ?</p>
  
  <p>After that i just add a line to my  code and output is completely different.
  my code is following:</p>
  
  <pre><code>int main()
  {
      int a, b;
      b=fork();
  </code></pre>
  
  <p>When i run the code the output is following
   2389my name is manish</p>
  
  <pre><code> the value of b = 0
  </code></pre>
  
  <p>Now I'm totally confused about the working of <code>fork()</code> call.</p>
  
  <p>My question are following:</p>
  
  <ol>
  <li>How <code>fork()</code> works?</li>
  <li>Where the control goes after the <code>fork()</code> call?</li>
  <li>Can any body explain why the outputs of codes written in problem?</li>
  <li>Why the output of <code>b</code> occurring at different places means in first code
  the output of <code>b = 2260</code> is just before the output <code>b = 0</code> while the value of <code>b = 2389</code> is not just before the <code>b = 0</code>?</li>
  </ol>
  
  <p>Please explain me the working of fork in the code written in the problem so that I can learn it properly . </p>