getenv - C stdlib.h

C examples for stdlib.h:getenv

Type

function

From


<cstdlib>
<stdlib.h>

Description

Get environment string

Prototype

char* getenv (const char* name);

Parameters

Parameter Description
name name of the requested variable.

Return Value

the value of the requested environment variable, or a null pointer if environment variable does not exist.

Example

Demo Code

#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;
}

Related Tutorials