getenv Function

Get a value for an environment variable.

Attention: This function is not implemented by MPLAB XC8 C compilers.

Include

<stdlib.h>

Prototype

char * getenv(const char * name);

Argument

name
name of environment variable to read

Return Value

Returns a pointer to the value of the environment variable if successful; otherwise, returns a null pointer.

Remarks

This function must be customized to be used as described (see pic30-libs). By default, there are no entries in the environment list for getenv to find.

Example

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  char *incvar;

  incvar = getenv("INCLUDE");
  if (incvar != NULL)
    printf("INCLUDE environment variable = %s\n", incvar);
  else
    printf("Cannot find environment variable INCLUDE ");
}

Example Output

Cannot find environment variable INCLUDE