title: Error: 'for' loop declarations only in c99 mode
body: <p>I am trying to compile this C code in my linux system (I am new to all of this) and I keep getting this error:</p>
  <pre><code>ForkCall.c: In function ‘main’:
    ForkCall.c:70:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
      for (int i=1; i&lt;=5; i++)
      ^
    ForkCall.c:70:1: note: use option -std=c99 or -std=gnu99 to compile your code
  </code></pre>
  <p>I tried declaring int i before the for loop, but got this error:</p>
  <pre><code>ForkCall.c: In function ‘main’:
    ForkCall.c:69:1: error: a label can only be part of a statement and a declaration is 
    not a statement
     int i;
  
     ^
  </code></pre>
  <p>This is the code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  
  int main()
  {
      pid_t pid, pid2;
      int n;
  
      printf(&quot;Select a number [1-5]: &quot;) ;
      scanf(&quot;%d&quot;, &amp;n);
      printf(&quot;\n\n&quot;);
  
      switch(n)
      {
      case 1:
          fork();
          printf(&quot;This is process %d\n&quot;, getpid());
          break;
  
      case 2:
          fork(); fork();
          printf(&quot;This is process %d\n&quot;, getpid());
          break;
  
      case 3:
          fork(); fork(); fork();
          printf(&quot;This is process %d\n&quot;, getpid());
          break;
  
      case 4:
          if((pid=fork()) &amp;&amp; (pid2 = fork())) {fork();}
          if((pid=fork()) &amp;&amp; (pid2 = fork())) {fork();}
          if ((pid=fork()) &amp;&amp; (pid2 = fork())) {fork();}
          printf(&quot;This is process %d\n&quot;, getpid());
          break;
  
      case 5:
          for (int i=1; i&lt;=5; i++)
          {
              fork();
          }
          printf(&quot;This is process %d\n&quot;, getpid());
          break;
  
      default:
          printf(&quot;Number not in range [1-5] !\n&quot;);
  
      }
  }
  ``
  </code></pre>