Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!uunet!unhd.unh.edu!jwm712 From: jwm712@unhd.unh.edu (Jonathan W Miner) Newsgroups: comp.lang.c Subject: Re: Appending environment variable to system calls... Message-ID: <1991Apr1.235953.22939@unhd.unh.edu> Date: 1 Apr 91 23:59:53 GMT References: <11697.27f376d8@zeus.unomaha.edu> <22200@yunexus.YorkU.CA> Organization: University of New Hampshire Lines: 32 In article <22200@yunexus.YorkU.CA> 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"); > > [ stuff deleted ] >Jeff Racine >racine@nexus.yorku.ca >racine@yunexus.UUCP The following may do what you want: char *s; char temp[256]; s=getenv("FOO"); sprintf(temp,"%s/FUBAR",s); system(temp); Better ways probably exist, take a look at the exec functioins. Jon. -- Jonathan Miner | I don't speak for UNH, and UNH does not jwm712@unhd.unh.edu | speak for me! (603)868-3416 | Hacking to survive......