Appending environment variable to system calls...
Everyone Knows JINX
jinx at milton.u.washington.edu
Tue Apr 2 09:35:26 AEST 1991
racine at yunexus.yorku.ca (Jeff Racine) writes:
>I wish to be able to set an environment variable (the path to a file)
>and then to execute a program using the system() function in the
>following fashion:
> char *s;
> s=getenv("FOO");
> system("FOO/FUBAR");
>or something like that. I am using Turbo-C running under MS-DOS, and
>the manuals do not seem to help me :-).
>I know this is a simple problem and that I am missing something
>obvious (such as I should not be using the system() function). I would
>really like some help on this approach (or rather the correct
>aproach).
To do this, I always did something like:
s = getenv("FOO");
sprintf (command_line, "%s/FUBAR", s);
system(command_line);
It uses an extra variable, but...
More information about the Comp.lang.c
mailing list