Running Program

I was wondering how to make a program open another program.
exec() or CreateProcess() on Windows.
It didnt Work.
What didn't work?
exec() or CreateProcess() on Windows.

Didn't work.
Last edited on
How did it not work?
Didn't work.


Better try something else then.
can you provide with what code you have written ?
In reply to Zhuge:
It wouldn't open a program.

In reply to firedraco:
I don't know what to try.

In reply to bluecoder:
No because I don't have any programming yet that control the opening of programs and because the code I do have has nothing to do with opening programs.
How do you know it didn't work if you didn't write any code?
well, do the fork and exec the another program in newly created process.

sample code.

int pid = fork()
if(pid==0)
{
exec("your program");
}

execv will overwrite the memory space of newly created process with your program.

Regards.
Is there an #include i'm forgeting cause the compiler says it dosent know what exec does.
Last edited on
You must include the process.h header for the exec functions (execl, execv etc). There is documentation for them here (you probably want to look at _execl)
http://msdn.microsoft.com/en-us/library/431x4c1w%28VS.80%29.aspx

Also in process.h are the spawn methods, which can also launch processes (probably want to look at _spawnl)
http://msdn.microsoft.com/en-us/library/20y988d2%28VS.80%29.aspx

Lastly there is the CreateProcess method in the Windows.h header
http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx

Give one or a couple of these a try, and if you are having difficulties, post your code and your problem for additional help.
If you post the code you have and post what platform you want to run it on, you may make speedier progress.

How To: Ask Questions The Smart Way
http://www.cplusplus.com/forum/articles/1295/
Topic archived. No new replies allowed.