![]() |
|
#1
|
|||
|
|||
compiling a program within another (C++)I have a menu program and would like to compile another C++ program from within it. I have tried using the shellexecute command, but was unable to get it to work. That doesn't mean I was using it correctly though. I might also like to pass on variables from the menu program to the one that I am running. Is this possible?
|
|
#2
|
||||
|
||||
|
Hi Siphiro. Welcome to these forums.
Maybe you could provide a bit more detail about what you are trying to do. More particularly what environment and compiler you are trying to do this with. It sounds like you are making a type of IDE where you could actually compile your code from within it. Basically, it should be fairly simple to do depending upon which compiler that you want to call. I have provided a small snippet here that may help. Please note that this is basic c syntax, but you should be able to change it into c++ syntax if you wish. CPP / C++ / C Code:
I believe the only header file that you should need is stdlib.h. Anyway, if you could provide more details, we may be able to help you out some more. |
|
#3
|
|||
|
|||
|
I am using Djgpp. Trying to run the "game" part of my program from my menu. I want them to be able to choose a saved game (already done) and then run the program. I have figured out how to get around passing variables from one to the other (just write them to a temp txt). So all I want is the command to run an exe from my code.
|
|
#4
|
||||
|
||||
|
Siphiro,
Sorry I misunderstood you. I thought you wanted to compile a program from a running program. However, the process is about the same. In fact it can be simply: CPP / C++ / C Code:
Note that you can pass parameters to this program as well, but your idea of passing data in a text file is probably easier. Note that the system call will wait until the called process is completed before continuing. If this is not the behavoir that you want then it may not work. |
|
#5
|
|||
|
|||
|
what is the library that is in?
|
|
#6
|
||||
|
||||
|
Quote:
stdlib.h It is an ANSI C compliant call. You said you were using djgpp, I would be surprised if it wasn't in that compiler. |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Loan Repayment program | Tripod | C Programming Language | 18 | 10-Mar-2004 12:00 |
| A question about the Amazon Affiliate Program | JdS | Advertising & Affiliates Forum | 5 | 13-Jan-2004 18:00 |
| how to run a program | saintsnow75 | C++ Forum | 1 | 27-Nov-2003 12:06 |
| error during program | rjd72285 | C++ Forum | 0 | 11-Nov-2003 19:49 |
| one program access another? | dgoulston | C++ Forum | 1 | 07-Oct-2003 12:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The