c++ - why getenv() can get name resolved without a std::? -


getenv() has c++ implementation can included in header file . member of namespace std. however, getenv() function can resolved correctly in code without std::getenv(), means follow program can compiled , run without error , warning. why getenv() name member of namespace std can resolved without std::? os , compiler ubuntu 12.04 i386 , g++ 4.8.1 respectively.

#include <cstdlib> #include <iostream>  int main() {     char * path_env;      path_env = getenv("path"); //without name resolve operation std::getenv()      std::cout << path_env << std::endl;      return 0; } 

try use search before asking questions. duplicate of why , how rand() exist both in global , std namespace in cstdlib?

c++11 standard: d.5 c standard library headers
para 3:

the header <cstdlib> assuredly provides declarations , definitions within namespace std. may provide these names within global namespace. header <stdlib.h> assuredly provides same declarations , definitions within global namespace, in c standard. may provide these names within namespace std.


Popular posts from this blog