Environment Names

ANSI 4.10.4.4   The set of environment names and the method for altering the environment list used by the getenv function

The set of environment names is unlimited.

To change environment variables from within a C program, call the _putenv function. To change environment variables from the command line in Windows 95 or Windows NT, use the SET command (for example, SET LIB = D:\ LIBS).

Environment variables set from within a C program exist only as long as their host copy of the operating system command shell is running (CMD.EXE in Windows NT and COMMAND.COM in Windows 95). For example, the line

system( SET LIB = D:\LIBS );

would run a copy of the Windows NT command shell (CMD.EXE), set the environment variable LIB, and return to the C program, exiting the secondary copy of CMD.EXE. Exiting that copy of CMD.EXE removes the temporary environment variable LIB.

This example also runs on the Windows 95 platform.

Likewise, changes made by the _putenv function last only until the program ends.