Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>putenv</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
putenv

Usage

   #include <stdlib.h>
   char *environ[];
   int putenv(char *newdef);

Description

   The putenv() function complements the getenv() function in the standard
   library. Passed a string, newdef, of the form "ENVAR=STUFF", it will set
   the environment variable ENVAR to the value STUFF. Note that this does
   not set the master environment and that the value set will be lost upon
   program termination! It is, however, useful for passing arguments in
   environment variables to spawned programs. Please note:

   1.  Since the environment table must be allowed to grow to accommodate
   added variables, this implementation does not allow modified environments

   to be passed to executed programs or those spawned using the P_OVERLAY
   mode.

   2.  When putenv() is called with an argument of the form "ENVAR=", if
   ENVAR exists in the current environment, it will be deleted.

   3.  The library getenv() function may be used to access environment
   variables set using putenv().

Example 

   #include <stdio.h>
   #include <stdlib.h>

   int main()
   {
       if (putenv("envar=new stuff")) {
           puts("can't modify environment");
           return EXIT_FAILURE;
       } else

           spawnlp(P_WAIT, "prog", "prog", "arg",
        NULL);
       return EXIT_SUCCESS;
   }

Return Value

   0 if successful, else -1

See Also

   getenv



See Also: getenv

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson