title: How to feed input in an c++ executable using NodeJS's child_process?
body: <p>I have installed mingw in my system to be able to compile c++ programs using terminal. I am creating a NodeJs api which when called with the C++ code and input compiled and generates output. For this I am using child_process of NodeJS.</p>
  <p>Now on terminal, when I open &quot;./a.exe&quot;, I need to feed input to it.But how to achieve that in Nodejs.
  Right now I am just able to compile the program that does not require inputs.</p>
  <pre><code>const compile_run = async (input) =&gt; {
    const myPromise = new Promise((resolve, reject) =&gt; {
      exec(&quot;g++ hello.cpp&quot;, (error, stdout, stderr) =&gt; {
        if (error) {
          console.log(`error: ${error.message}`);
          return;
        }
        if (stderr) {
          console.log(`stderr: ${stderr}`);
          return;
        }
        exec(&quot;./a&quot;, (error, stdout, stderr) =&gt; {
          if (error) {
            console.log(`error: ${error.message}`);
            return;
          }
          if (stderr) {
            console.log(`stderr: ${stderr}`);
            return;
          }
          resolve(stdout)
        });
      });
    });
  </code></pre>