Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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*?

like image 321
Curious Avatar asked Apr 24 '16 19:04

Curious


1 Answers

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.

like image 173
πάντα ῥεῖ Avatar answered Sep 18 '22 00:09

πάντα ῥεῖ