title: Calling C++ function from a C code
body: <p>So  I have looked <a href="https://stackoverflow.com/questions/2399344/calling-c-code-from-c">here</a> and <a href="http://www.parashift.com/c++-faq-lite/cpp-objs-passed-to-c.html" rel="nofollow noreferrer">here</a> and at a few other links mentioned in the first question and I have the following code already: </p>
  
  <p>The .cpp file:</p>
  
  <pre><code>#include "arp_piping.h"
  
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  
  std::string exec(char* cmd, FILE* pipe) {
      pipe = _popen(cmd, "r");
      if (!pipe) return "ERROR";
      char buffer[128];
      std::string result = "";
      while(!feof(pipe)) {
         if(fgets(buffer, 128, pipe) != NULL)
                result += buffer;
      }
      _pclose(pipe);
      return result;
  }
  </code></pre>
  
  <p>The header/linker file:</p>
  
  <pre><code>#ifndef ARP_PIPING_H
  #define ARP_PIPING_H
  #endif
  
  #ifdef __cplusplus
  #define EXTERNC extern "C"
  #else
  #define EXTERNC
  #endif
  
  my function goes here something like 
  EXTERNC .....exec(char* cmd, FILE* pipe) ????
  
  #undef EXTERNC
  </code></pre>
  
  <p>My question is what goes in the bit above as I am unsure what to be typing. I am trying to call the function in the .cpp file from my C main function <code>int main(int argc, char** argv) {}</code></p>