The function getenv () in C
Char * getenv (const char * name) function searches the environment string pointed to by the name parameter and returns the value associated with that string.
Char * getenv (const char * name) function searches the environment string pointed to by the name parameter and returns the value associated with that string.
Declare getenv () function in C
Here is the declaration for getenv () in C:
char * getenv ( const char * name )
Parameters
name : This is the string containing the name of the requested variable.
Returns the value
This function returns a string (terminated by null) with the value of the required environment variable, or returns NULL if the environment variable does not exist.
For example
The following C program illustrates the use of getenv () in C:
#include #include int main () { printf ( "PATH : %sn" , getenv ( "PATH" )); printf ( "HOME : %sn" , getenv ( "HOME" )); printf ( "ROOT : %sn" , getenv ( "ROOT" )); return ( 0 ); } Compiling and running the above C program will result:
According to Tutorialspoint
Previous lesson: Function exit () in C
Next lesson: Function system () in C
Discover more
parameter in C value of C pointer in C elements in CShare by
Marvin Fry
Update 25 May 2019
You should read it
- Call the function by pointer in C ++
- Pass cursor to function in C ++
- Function abs () in C
- The abort () function in C
- The function rand () in C
- The Quiet Details That Make a Sports Betting Platform Feel Reliable
- Instructions on creating toy set images with ChatGPT AI
- How are AI agents changing the journalism industry?
- System () function in C
- The function bsearch () in C
- The qsort () function in C