Borland C++ reference

getenv

raw OCR

Gets a string from environment.

Defined in header <stdlib.h>

Syntax

#include <stdlib.h>
char *getenv(const char *name);

Portability

DOSUNIXWindowsANSI CC++ only
■■■■

Remarks

getenv returns the value of a specified variable. On DOS, name must be uppercase. On other systems, name can be either uppercase or lowercase. name must not include the equal sign (=). If the specified environment variable does not exist, getenv returns a NULL pointer.

Return value

On success, getenv returns the value associated with name. If the specified name is not defined in the environment, getenv returns a NULL pointer.

bz^

Environment entries must not be changed directly. If you want to change an environment value, you must use putenv.

See also

Example

#include <stdlib.h>
#include <stdio.h>
int main(void)
{
   char *s;
/* get the comspec environment  parameter */
   s=getenv("COMSPEC");
/* display comspec parameter  */
   printf("Command processor:  %s\n",s);
   return 0;
}

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.