Calling up code to be compiled automatically

So I have a program and it writes a new (modified) copy of itself to a file.cpp. How can I get the program to call up my compiler to compile this new source file?
Depends which compiler and which platform... for MinGW GNU C++ under Windows, something like:

system( "g++ file.cpp -o file2.exe" );

perhaps? (usually you won't be able to write to an executable image while it's running, thus the use of a different filename there).
Last edited on
Topic archived. No new replies allowed.