Re: system() function
- From: jasen <jasen@xxxxxxxxxxx>
- Date: 22 Mar 2007 19:50:54 GMT
On 2007-03-21, gio <giorginooo.rossi@xxxxxxxx> wrote:
I have a problem and the solution should works under windows and unix
OS.
Suppose I have a program ex.c in the directory X (so the current
working directory of ex.c is X).
Also suppose I have this code fragment:
...
char otherpath[PATHLEN];
char cmd[CMDLEN];
...
...
otherpath="Y" //where y is a valid path string
...
system(cmd); //where cmd is any command string
...
If in cmd is specified a relative path, it is relative to the current
working directory(in this example is X).
There is a way to execute command wich paths are relatives to the
"otherpath" variable (in this example is Y)?
chdir(otherpath);
system(cmd);
chdir(getenv("PWD")); // optional: change back...
--
Bye.
Jasen
.
- References:
- system() function
- From: gio
- system() function
- Prev by Date: Re: windows .dll files and linux
- Next by Date: Re: system() function
- Previous by thread: Re: system() function
- Next by thread: File Handling
- Index(es):
Relevant Pages
|