March 31st, 2003, 08:18 AM
how to execute a programme within a programme ?
How do I execute a programme within a C programme ?
any good docs articles on this ?
March 31st, 2003, 09:17 AM
If you are using a DOS/Windows C compiler, it should also have implemented system(). Just read the help file/documentation on it.
When you use system(), the calling process is still there and can check the status returned by the system() call.
However, if you want to have the called program replace the calling program, then look into the exec* family of functions.
March 31st, 2003, 05:34 PM
I recall reading a few weeks ago that the system command is VERY slow. Be sure to read the documentation like dwise1_aol suggested. I think it provides an alternative.
March 31st, 2003, 07:39 PM
The man page on Linux also mentions some gotcha's regarding signals, I think. It didn't apply to what I was doing, so I didn't pay much attention.
And don't just read the documentation, but also write some test code.
jason i noticed u said system is very slow? what about execve?
In both Windows and Linux, execve would replace the calling program. In Linux we'd couple it with a fork, but Windows doesn't do forks -- there's CreateProcess which works quite differently.
However, Jason_G never replied, so we don't know what OS he's running or whether exec* would work for him or not.