get and put environment variables in C++


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // char * getenv(const char * name);
  2. // int putenv(const char * var);
  3.  
  4. // getenv example
  5. std::string HOME_PATH = getenv("HOME");
  6.  
  7. // putenv example
  8. int stat = putenv("TEMP="/tmp");
  9. if( !stat ) {
  10. cout<<"failed to define environment variable"<<endl;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.