title: Variable declaration placement in C
body: <p>I long thought that in C, all variables had to be declared at the beginning of the function. I know that in C99, the rules are the same as in C++, but what are the variable declaration placement rules for C89/ANSI C?</p>
  
  <p>The following code compiles successfully with <code>gcc -std=c89</code> and <code>gcc -ansi</code>:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main() {
      int i;
      for (i = 0; i &lt; 10; i++) {
          char c = (i % 95) + 32;
          printf("%i: %c\n", i, c);
          char *s;
          s = "some string";
          puts(s);
      }
      return 0;
  }
  </code></pre>
  
  <p>Shouldn't the declarations of <code>c</code> and <code>s</code> cause an error in C89/ANSI mode?</p>