title: C Local variable has same name as function - how does it work?
body: <p>I teach C to absolute beginners and I have noticed that some of my students get the notion to use the same name for the function and a local variable in the function. I think it's goofy and would prevent recursion.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>int add2numbers (int a, int b) { /* Tested on Mac OS X with gcc */
      int add2numbers = a + b;
      return add2numbers;
  }
  </code></pre>
  
  <p>The way I understand how it works is that the variable is in the local scope of the function, and the function is in the global scope. </p>
  
  <p>So, the questions...  </p>
  
  <ol>
  <li>Am I understanding this correctly?  </li>
  <li>Where the h*** are they getting that idea from?  </li>
  </ol>
  
  <p>Thanks</p>