Quote:
Originally Posted by exvor
Why not just incorporate the c program into the GUI program?
|
That would indeed be the way to do it, with the following wrinkle:
Quote:
Originally Posted by exvor
I suppose you could just use a system call but that would not be advisable.
|
A call to
system() might be just the thing to do. If you sometimes or often use that other program stand-alone, without using GTK+, it would be helpful from a maintenance point of view to keep the two programs (the one using GTK+ and the one it wants to run) separate. That way, if you want to make an improvement in the called program, you can make the change in only one place and it will be made for both the stand-alone operation and the GTK+ program.
If the stand-alone program produces output (a little or a lot), you have a couple of options.
- Don't really use system(); instead, use fork(), exec(), and waitpid(), and use pipes to read the output.
- In a system() call, direct the output to a file, just as you would if you were at a shell prompt:
Code:
if(system("fred_program > fred_output.txt"))
{
/* do error recovery here */
}