Get a value for an environment variable.
Include
<stdlib.h>
Prototype
char *getenv(const char *name);
Argument
name
|
name of environment variable |
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> /* for printf, NULL */
#include <stdlib.h> /* for getenv */
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