Is it possible (and if so, how) to write a program in C++ that takes parameters, then run that program from another C++ program.
Ie: I can create a function that adds two numbers:
int add(int a,int b){return a+b;}
Is it possible to do the same thing, except instead of a function, a separate C++ .exe?
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.
I want to have a program, lets call it "p1".
I want that program to get two numbers from the user:
int x,y;
cin>>x;
cin>>y;
Now I want to create another program, that takes two numbers, and adds them, the same way a function would, except a seperate program.
Then I want to run the second program from the first program with the numbers it got from the user. Ie:
#include<iostream>
using namespace std;
int main()
{
int x,y;
cin>>x;
cin>>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;
}
EDIT: I figured out how to use
(void)system("C:\\Program Files\\test.exe");
How would I use that to pass arguments, and how could I write a program that takes those arguments?