Mail Archives: djgpp/2000/02/03/03:12:16
On Wed, 2 Feb 2000, wriska wrote:
> I am trying to set DOS environment variables from within a DJGPP
> C program, but I am not having much success. Would someone
> please be kind enough to post a snippet of code that could do
> this? I am looking for something to be flexible enough to allow
> for varying environment variable names as well as values.
There are library functions `setenv' and `putenv', look them up in the
library docs. Their use is pretty much obvious; `putenv's docs
includes an example.
Btw, you aren't trying to change the environment of the shell from
which you run your programs, are you? If that's what you are trying
to do, forget it: it's not possible. Programs can only change the
environment of the child programs they invoke, not of their parents.
(Well, actually, it *is* possible to change the environment of the
parent shell, but it involves walking the DOS memory chain, which is
very complicated and totally unportable.)
- Raw text -