home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!caen!sol.ctr.columbia.edu!sal.wisc.edu!alan
- From: alan@sal.wisc.edu (Alan Watson)
- Subject: Re: putenv question
- Message-ID: <1992Nov24.032314.19535@sal.wisc.edu>
- Organization: Space Astronomy Lab, Madison WI
- References: <1992Nov23.204330.13594@news.miami.edu>
- Distribution: na
- Date: Tue, 24 Nov 1992 03:23:14 GMT
- Lines: 13
-
- In article <1992Nov23.204330.13594@news.miami.edu> aem@news.miami.edu (andrew mossberg) writes:
- >
- >I'm trying to read a file and place lines found there into the environment
- >via putenv, but it isn't cooperating. It works fine when I hardcode
- >values into the putenv calls, like putenv("SSS=adas");, but reading
- >a file using fgets() and then putenv'ing the line (sans trailing newline)
- >only leave the last line in the environment.
-
- When you use putenv, the argument string becomes part of the environment;
- consequently, if you change the contents of the string (by reading another
- line), you will overwrite your previous change.
-
- Try malloc-ing a new string for each line.
-