You are here:

C++/Executing a program from another program


How to execute a program from another program? For example: i want to execute "START.cpp" from "MAIN.cpp". I do not want to use .exe file directly.Instead i want to execute "START.cpp" from "MAIN.cpp".

Hello krutthika, thank you for the question.

A .cpp file is nothing more than a text file. It cannot be executed by itself. You have to let the compiler parse the text, generate machine code, and then link it into an executable, which can then be run on Windows machines.

If your goal is to call 1 executable file from another, then you should compile each of your source files into separate applications. Then, in the program you wish to call the others from, you can use a C function called "system()". It takes an executable file as a parameter.

Here is an example:

// Let's call the Windows built in calculator from our program

// in main.cpp

int main()
return 0;

Please note that unless the directory your executable file is in is in your system's PATH environment variable, you will need to use an absolute path.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 All rights reserved.