title: How to use a function which was declared in more than one header
body: <p>so I have three files, <strong>main.c, a.h, b.h</strong>.<br>
  In all three files I have declared the following function</p>
  <pre><code>int test(int a, int b)
  {
    if(a&gt;b)
      return a;
    else return b;
  }
  </code></pre>
  <p>Is there anyway I can use the function in the main program but from different locations (from a.h, then from b.h and then from main.c), because now I have this error: <strong>error: redefinition of test</strong>?</p>
  <p>For a better understanding I will post the statement here:</p>
  <blockquote>
  <p>Write test() in two libraries, a.h and b.h. Include both libraries in a program. Investigate how can
  I use test() from a.h or b.h. What if I define test() also in the main program and I want to use the
  test() from main program, library a.h or b.h ?</p>
  </blockquote>
  <p>The code in main.c is like this:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &quot;a.h&quot;
  #include &quot;b.h&quot;
  int test(int a, int b) //Function for showing the max
  {
      if(a &gt; b)
          return a;
      else return b;
  }
  
  int main()
  {
      int a, b;
      scanf(&quot;%d %d&quot;, &amp;a, &amp;b);
      test(a, b);
  
      return 0;
  }
  </code></pre>
  <p>The code in a.h is identical with the one from b.h:</p>
  <pre><code>#ifndef CODE_a_H
  #define CODE_a_H
  
  int test(int a, int b) //Function for showing the max
  {
      if(a &gt; b)
          return a;
      else return b;
  }
  
  #endif
  </code></pre>