getenv()

Accesses the environment list.

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

name

A pointer to a character string containing the variable to search for.

Remarks

getenv() returns a pointer to the value of the environment value, encoded as a character string. It returns NULL on failure.

Listing: Example of getenv() usage

#include <stdio.h>

#include <stdlib.h>

int main(void)

{

char *value;

char *var = "path";

if( (value = getenv(var)) == NULL)

printf("%s is not a environmental variable", var);

else

printf("%s = %s \n", var, value);

return 0;

}

Output:

path = c:\Program Files\Freescale\codewarrior;c:\WINNT\system32