title: How do curly braces and scope wоrk in C?
body: <p>I'm currently trying to learn some C in my spare time. I have some experience in Java, and I'm therefore used to limit scoping of i.e. variables with curly braces. But I'm a bit confused, as it seems like Brian W. Kernighan/Dennis M. Ritchie's book "The C Programming Language" doesn't use a lot of curly braces, where I would assume it's normal to use them (from a Java perspective). E.g. 1.6 in the book where the code is: </p>
  
  <pre><code>while((c = getchar())) != EOF)
      if (c &gt;= '0' &amp;&amp; c &lt;= '9')
          ++ndigit[c-'0'];
      else if() /*and so forth...*/
          ++nwhite;
      else
          ++nother;
  </code></pre>
  
  <p>From a Java perspective I'm used to that only the first statement would be run then, because of the lack of curly braces, but the indentation suggests that everything will run (if, else if and else).</p>
  
  <p>So what I'm asking is: What would run here, and why would it run? Are if, else if and else all in the scope of the while loop? Are there any conventions to refer to, that I can read to try to understand it better? Thanks in advance.</p>