Chat on IRC |
c++ question
Posted by gbyte222 [send private reply] at January 01, 2003, 04:54:48 PM
How do I call a program from within another program in c++?
Posted by Psion [send private reply] at January 01, 2003, 05:57:54 PM
The easy way is the ANSI system() function. The harder and more flexible way is, if you're using a Posix system, execve() and related functions.
Posted by gbyte222 [send private reply] at January 01, 2003, 06:00:17 PM
thanx, can you guve me an example to make sure i am understanding this right
Posted by gian [send private reply] at January 01, 2003, 09:59:56 PM
void main(void) { system("ls"); }
Posted by whizkide [send private reply] at January 02, 2003, 01:02:11 PM
if you are doing Win32 u might wanna use CreateProcess();
Posted by unknown_lamer [send private reply] at January 02, 2003, 03:52:09 PM
#include <sys/types.h> #include <unistd.h> int main (int argc, char *argv[]) { pid_t sub_process; sub_process = fork (); if (sub_process == 0) /* we are the child */ { execvp (argv[1], argv+1); } return 0; } If you compile that as fexec you can do 'fexec foo bar baz' to run 'foo bar baz' in the background.
Posted by gbyte222 [send private reply] at January 02, 2003, 05:00:11 PM
Thanx
Register as a new user | |||||||||