putenv()                 Create New Environment Variables
 
 #include   <stdlib.h>                   Required for declarations only
 
 int        putenv(envstring);
 char       *envstring;                  Environment string definition
 
    putenv() adds new environment variables or modifies existing ones.
    'envstring' must be a pointer to a string with the form:
 
                        varname = string
 
    where 'varname' is the name of the environment variable to be added
    or modified, and 'string' is the variable's value (for example:
    "INCLUDE = C:\INCLUDE").  If the specified 'varname' is already set,
    its value is replaced by 'string'.  If it is not already set,
    '*envstring' is added to the environment.
 
    Returns:    Zero, if successful.  -1 is returned if an error occurs.
 
      Notes:    Do not free a pointer to an environment variable while
                the entry is still in use, or the environment variable
                will point into freed space.  This can effectively happen
                if you pass a pointer to a local variable to putenv(),
                and then exit the function in which the local variable
                was declared.
 
  -------------------------------- Example ---------------------------------
 
    The following statements change the PATH to C:\WORK, and then print
    an appropriate message.
 
            #include <stdlib.h>
            int result;
 
            main()
            {
                 if ((result = putenv("PATH = C:\WORK")) == 0)
                         printf("path changed to C:\\WORK");
             }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster