Daily bit(e) of C++ | std::getenv
Daily bit(e) of C++ #416, Accessing environment variables using std::getenv.
On POSIX systems, the environment variables can be accessed through the global variable char** environ. This variable is also typically passed as the third argument to main.
For a portable solution, the standard offers the std::getenv function. Note that while the function returns char*, modifying the returned string is UB.