title: How do I execute a command and get the output of the command within C++ using POSIX?
body: <p>I am looking for a way to get the output of a command when it is run from within a C++ program.  I have looked at using the <code>system()</code> function, but that will just execute a command. Here's an example of what I'm looking for:</p>
  
  <pre><code>std::string result = system("./some_command");
  </code></pre>
  
  <p>I need to run an arbitrary command and get its output. I've looked at <a href="https://www.boost.org/" rel="noreferrer">boost.org</a>, but I have not found anything that will give me what I need.</p>