C:getenv
lastmod 2026-11-10created 2016-01-183 edits
getenv() is a C standard library function that, given a name, returns a string pointer to the value of that environment variable of the current process, and returns NULL if the variable does not exist. It is declared in the stdlib.h header (std::getenv in cstdlib in C++); the returned string must not be modified and may be invalidated by later calls to setenv or putenv. It is commonly used to read values such as the home directory (HOME, USERPROFILE), the temporary path (TMPDIR), and PATH to handle platform-specific settings.