Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!ogicse!milton!jinx From: jinx@milton.u.washington.edu (Everyone Knows JINX) Newsgroups: comp.lang.c Subject: Re: Appending environment variable to system calls... Message-ID: <1991Apr1.233526.21647@milton.u.washington.edu> Date: 1 Apr 91 23:35:26 GMT Article-I.D.: milton.1991Apr1.233526.21647 References: <11697.27f376d8@zeus.unomaha.edu> <22200@yunexus.YorkU.CA> Organization: University of Washington Lines: 25 racine@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...