C examples for stdlib.h:getenv
function
<cstdlib> <stdlib.h>
Get environment string
char* getenv (const char* name);
Parameter | Description |
---|---|
name | name of the requested variable. |
the value of the requested environment variable, or a null pointer if environment variable does not exist.
#include <stdio.h> /* printf */ #include <stdlib.h> /* getenv */ int main ()/* ww w. j a va2 s . c o m*/ { char* pPath; pPath = getenv ("PATH"); if (pPath!=NULL) printf ("The current path is: %s",pPath); return 0; }