title: Name Mangling in C++
body: <p>I was going through the article - <a href="http://www.geeksforgeeks.org/extern-c-in-c/">http://www.geeksforgeeks.org/extern-c-in-c/</a></p>
  
  <p>There are two example given - </p>
  
  <pre><code>int printf(const char *format,...);
  
  int main()
  {
      printf("GeeksforGeeks");
      return 0;
  }
  </code></pre>
  
  <p>It say this wont compile because the compiler wont be able to find the mangled version of 'printf' function. However, the below give output.</p>
  
  <pre><code>extern "C"
  {
      int printf(const char *format,...);
  }
  
  int main()
  {
      printf("GeeksforGeeks");
      return 0;
  }
  </code></pre>
  
  <p>This is beacuse extern "C" block prevent the name from being mangled. However, the code run and gives output. From where does it get the definition of 'printf'. I read a post which says 'stdio.h' is included by default. If this is true, below code must run. However, it give error that printf is not defined.</p>
  
  <pre><code>int main()
  {
      printf("GeeksforGeeks");
      return 0;
  }
  </code></pre>
  
  <p>Can somebody explain this?</p>