home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 17089 < prev    next >
Encoding:
Text File  |  1992-11-24  |  1.0 KB  |  25 lines

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