Q: Why does getenv() return a non-const string I was reading documentation for the std::getenv() function on cppreference.com and it says 

Modifying the string returned by getenv invokes undefined behavior.

Then why does the function not return a const char*?

A: 
Then why does the function not return a const char*?

Probably because of compatibility with older c standards that don't support const at all.
