Function name : getenv
Header file : <stdlib.h>
Function prototype : char *getenv(char *name);
Function : used to get the string in the current environment
Parameter : char *name is the environment variable name
Return value : Returns the given environment variable value. If the specified environment variable is not defined in the environment, NULL is returned;
Program example : Use this function to obtain the first address of the environment string named COMSPEC and display it.
#include<stdio.h>#include<stdlib.h>#include<string.h>intmain(void){char*s=getenv(COMSPEC);printf(Commandprocessor:%sn,s);return0;}
Running results
Commandprocessor:C:Windowssystem32cmd.exe