title: About .c file and .h file in C programing?
body: <p>there is a function <code>f</code> in <code>foo.c</code>, I put <code>f Prototypes</code> into a <strong>header file</strong>.</p>
  
  <p>and then, there are 3 question:</p>
  
  <ol>
  <li>does <strong>header file</strong> must named <code>foo.h</code>?</li>
  <li>does <code>foo.c</code> and <code>foo.h</code> must be in the same <strong>directory</strong>   ?</li>
  <li>If the answer to both questions is <strong>no</strong>, that is to say, a header file can named <code>f.h</code>, <code>foo.c</code> and <code>f.h</code> can be in different directory. look a example:</li>
  </ol>
  
  <p><strong>~/cfile/foo.c</strong></p>
  
  <pre><code>#include "~/hfile/f.h"
  int f(void){
       ...
  }
  </code></pre>
  
  <p><strong>~/hfile/f.h</strong></p>
  
  <pre><code>int f(void);
  </code></pre>
  
  <p><strong>~/main/cmain.c</strong></p>
  
  <pre><code>#include "~/hfile/f.h"
  int main(void){
      f(); 
      ...  
  }
  </code></pre>
  
  <p>Then, when I call <code>f</code> function in <strong>cmain.c</strong>, <strong>cmain.c</strong> can find <strong>f.h</strong>  by <code>#include</code> directive, but how <strong>cmain.c</strong> find <strong>foo.c</strong> by <strong>f.h</strong>, because <strong>cmain.c</strong> only include <strong>f.h</strong>  not include <strong>foo.c</strong>?  or how the compiler or linker find <strong>foo.c</strong> by <strong>f.h</strong>?</p>