I am developing a project in which i want to run 2 programs simultaneously in such a way that when the user runs 1st program,the 2nd program gets called from the 1st program and now both the 1st program and the 2nd program start executing simultaneously.

For ex :Suppose there is a program called work.exe in my current directory.

now i would call it in the following code


void main()

               printf("Hi!,How are you?");

The work.exe prints ("Hello!") on the screen.

Now i want that both "Hello!" and "Hi!How are you?" gets printer simultaneosly and contineously on the screen.

Normally what happens that when we call another program from our code through the system command,then till the execution of the called program stops,the code of the calling program doesn't gets executed.

Hence i want that both the called program and the calling program gets executed simultaneously.

Any suggestions,Kindly help.I am just stucked very badly in my project due to this.

Thanks in advance.

Rituraj Raina

If your working with MFC, theres a function


That will launch an exe in its own thread. Its up to you to keep peeking at any messages it sends. Dont know if this is what you want, but its the closest thing i could think of

i think after the execution of "work.exe" the c++ exits from the whole process. to stop this don`t use void main() in the "work.cpp" but use any other function, say
void printhello()

and then do whatever u want to in the "work.cpp" and close the function.
now after creating the first program, in the second proram include the file work.cpp with the other header files like this

and then call the function from anywhere inside the main() function and it will work.

This article has been dead for over six months. Start a new discussion instead.