954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to execute a program within another program?

Hello sir,

I am doing project on processors. I have a program called "START" and another program called "main". Now, i want to execute "START" program within the "main". I do not want to just call instead i want to run the "START" Program. please help me..


Thanku
Krutthika

krutthika
Newbie Poster
6 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

Try

system("sh test");
system("test.exe");

i think you will need the header 'process.h' for this.

Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
 

1> you dont need to create separate threads for same problem. you could have 'edit'ed your earlier post instead or if it was replied to you could have again 'replied' with your query.
2>system should execute any executable, it need not have a .exe extension, as per my understanding if you're on *NIX you can give the name of any file which has execute permission.

Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
 

hello ,
Thanks for replying..
I shlould not use .exe file in my program. I need to execute when i call the "START" program in the "MAIN" .. Please help

krutthika
Newbie Poster
6 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

what is 'START' program? is it a shell script or is it a .exe file? Are you on windows or *NIX?

Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
 

Hello,

"START" is a c++ program , within that program i have written 3 programs - bubble sort, concatenation, string read programs written using functions. I have seperated all these functions and stored in a seperate files without headers.. Now, I have to write a program for accepting the functions by calling it then execute these functions seperately. Execution is done seperately by writing 3 accepting programs. For that i have to write a program for accepting the functions then execute those functions. Example consider "MAIN" is accepting program and it accepts Bubble sort function then Bubble sort function should execute and "MAIN" should also execute. Now my question is How to execute a program within another program?? Please guide.

Thank you once again..
Krutthika

krutthika
Newbie Poster
6 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

Why do you need to write and call separate c++ programs for each of these functions to execute? Is there a special requirement to do this? Was writing different function not allowed? if you still have to do it i think you can do this by using the 'system' command and giving the program name without any extension. I still fail to understand the requirement though and would like to attach a 'Do at your own risk' tag to it :)

Just out of curiosity, you do know that if you call a function from 'MAIN', main will not terminate till the control returns back from the function, right?

Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
 

Hello sir,
That is the assignment given to me.. Is their any subroutine type to call a program and execute then continue the main program?? As we do in 8085 processors...

Thanku
Krutthika

krutthika
Newbie Poster
6 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

If you really need to then I would consider using the following.

Personally ( I think you might be confused )
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044654269&id=1043284392

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You