title: How to create C API to C++ Function
body: <p>I am learning how to generate an array of random numbers in C++. I am using a std::vector and std::generate (I'm trying to use modern idiomatic C++ - not sure how well I'm doing). </p>
  
  <p>What I would like to do is to expose this function to plain old C code. How can make this function available from C? </p>
  
  <p>Code below. Thanks!</p>
  
  <pre><code>void RandomArray(std::vector&lt;double&gt; &amp;data)
  {
      std::random_device rd{};
      auto mtgen = std::mt19937{ rd() };
      auto ud = std::uniform_int_distribution&lt;&gt;{ 1, 6 };
      auto gen = [&amp;ud, &amp;mtgen](){ return ud(mtgen); };
  
      std::generate(data.begin(), data.end(), gen);
  }
  </code></pre>