A null-terminated string representing the name of the environment variable to retrieve
Read more about parameters of getenv in parameters section
The getenvfunction in C language Retrieves the value of an environment variable.
The getenv function searches the environment list for a string that matches the string pointed to by name. The environment list is a system-dependent array of strings of the form name=value. The search is case-sensitive on some systems.
The getenvfunction takes 1
parameter:
•
const char * `name`: A null-terminated string representing the name of the environment variable to retrieve
Retrieves the value of the environment variable specified by `name`. Returns a pointer to a null-terminated string containing the value of the variable, or `NULL` if the variable is not found.
The getenv function return value :
Returns a pointer to the value in the environment, or NULL if there is no match
The returned string should not be modified by the program
Output
This example demonstrates how to retrieve and print the value of the PATH environment variable.