title: The text to be printed is being printed on the command line rather than print space while using fork on terminal
body: <p>So in the ubuntu terminal, when I run a simple piece of code using fork to print from the child as well as parent process, the terminal prints the child process' print statement on command line rather than before it. I want to know if there is a way around it.</p>
  
  <p>I am a bit new to using syscalls so I really didn't try many things</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  int main(int argc, char* argv[]){
      printf("(%d) Start\n", (int)getpid());
      int rc = fork();
      if(rc &lt; 0 ){
          fprintf(stderr, "Error\n");
          exit(1);
      }
      else if(rc == 0){
          printf("(%d) Hello from the child, I got %d. My parent is %d\n", (int)getpid(), (int)rc, (int)getppid());
      }
      else{
          printf("(%d) Hello from the parent, I got %d. My parent is %d\n", (int)getpid(), (int)rc, (int)getppid());
      }
      return 0;
  }
  </code></pre>
  
  <p>I expected the the printed statements to all be in between two command lines, but the last line kept being printed on the command line:</p>
  
  <p><img src="https://i.stack.imgur.com/c5OJ0.png" alt=""></p>