INFO: Storage of Environment Variables (43428)
The information in this article applies to:
- The C Run-Time (CRT), when used with:
- Microsoft Visual C++ for Windows, 16-bit edition 1.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 5.0
- Microsoft Visual C++, 32-bit Editions 6.0
This article was previously published under Q43428 SUMMARY
The environ variable is an array of pointers to the strings that constitute
the process's environment. The C startup code takes the environment
information and initializes the environ variable to point to the
environment table. The function getenv() uses the environ variable to
access the environment table. environ can be used to obtain the environment
table address directly.
The following program prints out the address of the beginning of the
environment table and the PATH environment variable:
Sample Code
#include <stdlib.h>
#include <stdio.h>
char *path;
void main (void)
{
path = getenv( "PATH" );
printf( "path: %s\nenviron: %x\n", path, environ );
}
Modification Type: | Major | Last Reviewed: | 12/12/2003 |
---|
Keywords: | kbcode kbCRT kbinfo KB43428 kbAudDeveloper |
---|
|