title: How to create/run a .exe from a program? (C++)
body: <p>Is it possible (and if so, how) to write a program in C++ that takes parameters, then run that program from another C++ program.</p>
  
  <p>Ie:  I can create a function that adds two numbers:</p>
  
  <pre><code>int add(int a,int b){return a+b;}
  </code></pre>
  
  <p>Is it possible to do the same thing, except instead of a function, a separate C++ .exe?</p>
  
  <p>EDIT: Since a lot of people don't understand my question, I'll try to say exactly what I want to know how to do.</p>
  
  <p>I want to have a program, lets call it "p1".</p>
  
  <p>I want that program to get two numbers from the user:</p>
  
  <pre><code>int x,y;
  cin&gt;&gt;x;
  cin&gt;&gt;y;
  </code></pre>
  
  <p>Now I want to create another program, that takes two numbers, and adds them, the same way a function would, except a seperate program.</p>
  
  <p>Then I want to run the second program from the first program with the numbers it got from the user. Ie:</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  int main()
  {
       int x,y;
       cin&gt;&gt;x;
       cin&gt;&gt;y;
       add(x,y); //this is how I would call a function named "add".  I want to know how to do that with a separate program instead of just a separate function.
       return 0;
  }
  </code></pre>
  
  <p>EDIT: I figured out how to use</p>
  
  <pre><code>(void)system("C:\\Program Files\\test.exe");
  </code></pre>
  
  <p>How would I use that to pass arguments, and how could I write a program that takes those arguments?</p>