title: How to create external API for program?
body: <p>For example, I have a simple program like this:</p>
  
  <pre><code>//Program A
  #include &lt;stdio.h&gt;
  
  int add(int a, int b)
  {
      return a + b;
  }
  
  int sub(int a, int b)
  {
      return a - b;
  }
  
  int main(void) {
      doSomeStuff();
      return 0;
  }
  </code></pre>
  
  <p>I have started it and it is running. And have program B.
  My questions are: </p>
  
  <ol>
  <li>How can I connect from my program B to program A and ask it to run, for example, function add?</li>
  <li>How can I write external API for always running program A?</li>
  </ol>
  
  <p>Or, maybe similar example, think about some database and driver for it. How can driver request a database?</p>