title: How to move C functions into separate file?
body: <p>I'm getting started with C programming. I currently have a large file that contains a lot of functions. I would like to move these functions to a separate file so that the code is easier to read. However, I can't seem to figure out how to properly include/compile and can't find an example in any online tutorials that I've found. Here's a simplified example:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  void func1(void) {
    printf("Function 1!\n");
  }
  
  void func2(void) {
    printf("Function 2!\n");
  }
  
  int main(void) {
    func1();
    func2();
    return 0;
  }
  </code></pre>
  
  <p>How do you move C functions into a separate file? FYI: I'm using gcc.</p>
  
  <p><strong>Update:</strong> These answers are very helpful, thank you. Now it seems that my simplified example is not good enough because I realized the reason my program failed to compile is because I'm using a global variable in my functions.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  int counter = 0;
  
  void func1(void) {
    printf("Function 1!\n");
    counter++;
  }
  
  int main(void) {
    func1();
    return 0;
  }
  </code></pre>
  
  <p>Moving these functions to an external file doesn't work because they need to reference this global variable:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include "functions.c"
  
  int counter = 0;
  
  int main(void) {
    func1();
    counter = 100;
    return 0;
  }
  </code></pre>
  
  <p>How can I get around this issue?</p>