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;
   system("pause>null");
}

Recommended Answers

All 2 Replies

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().

Brilliant, works well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.