Does anyone know how to call a binary executable file from another program.
I have a simple binary file which can take command line arguments called InputProgram.exe.

I have made another program of which I want to call InputProgram from and pass it an argument.
Not this is going to look naive but this is what I have. It doesn't work?

I genuinly don't know how to do it?

include <iostream>
#include <cstdlib>

using namespace std;

int main()
   char x;
   cin >> x;
   cout << x + " " + (InputProgram p) << endl;

Edited by daino: correction

5 Years
Discussion Span
Last Post by daino

You are already using the function that you are looking for. The function system() executes a command. In this case, you are executing the "pause" command. You can use the same function to execute other commands, including your own program. It's as simple as that:

system("InputProgram.exe myargument");

There are also more native Windows functions to do the same (with a bit more control), such as CreateProcess().

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.