title: Why I need C header files?
body: <p>It is a dumb question, I admit. Code will explain it better. Got these files:</p>
  
  <p>hello.c:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void hello(char * s)
  {
      printf("hello, %s\n", s);
  }
  </code></pre>
  
  <p>main.c:</p>
  
  <pre><code>int main()
  {
      hello("world!");
      return 0;
  }
  </code></pre>
  
  <p>makefile:</p>
  
  <pre><code>test : main.o hello.o
      gcc -o test main.o hello.o
  
  main.o : main.c
      gcc -c main.c
  
  hello.o : hello.c
      gcc -c hello.c
  
  .PHONY : clean
  clean :
      -rm test
      -rm main.o
      -rm hello.o
  </code></pre>
  
  <p>I can just "make" and "./test" it and it works.
  Shouldn't I need to include something like hello.h in main.c just so the compiler knows the function prototype?</p>
  
  <p>I didn't even include hello.c anywhere and it just works! How come main.c knows about the hello function?</p>
  
  <p>If that works, when do I need .h files? I am new to C programming but I thought this concept was easy to grasp, now I am completely confused.</p>