On Aug 21, 3:39 pm, "BobR" <removeBadB...@worldnet.att.net> wrote:
<mbrig...@gmail.com> wrote in message...
What I am trying to do is to create a very basic A-life simulator.
What I can't figure out is how to read and execute C++ code from a
file, if I could do this it would be simple to make custom files or
have the main program make them.
Any help would be appreciated.
Just compile it, [check output], and run it using 'system()'.
[ untested. just for an idea. ]
std::string comp( "g++ " );
std::string cpplibs( "-lmylib " );
std::string cppfile( "MyFile.cpp " );
std::string Command = "\"" + comp + cppfile + cpplibs + "\"";
system( Command );
// check it here
system( MyFile );
Get the source for some IDE, and examine how they do it.
--
Bob R
POVrookie
Can you explain that a bit more? It might be just what I need.
Just to clear up what I need it for:
I need it the main program to dynamically (At runtime) genarate code.
The only way I can see for this to be done is to (have the program)
write it to a file then load it back at a later time.
I need to be able to create and run a large number of files without
having to code in a loading mechanism for each one.
that your program can then load and execute some function.
However, an interpreter is probably better. You can probably find some C++
such as maybe python.