getenv

What can I do if getcwd() and getenv("PWD") don't match?

I have a build system tool that is using getcwd() to get the current working directory. That's great, except that sometimes people have spaces in their paths, which isn't supported by the build system. You'd think that you could just make a symbolic link: ln -s "Directory With Spaces" DirectoryWithoutSpaces And then be happy. But u...

Deleting char array returned by getenv()

Should I free the memory allocated for the char array, pointer to which is returned by the char * getenv( char * ) function? And which way - C free() or C+ delete []? If no - why? I mean: char * ptr = getenv( "LS_COLORS" ); cout << ptr << endl; delete [] ptr; //Is this or free() call needed? Thank you. ...

C++ assign const to environment variable or default value

For an application that uses a number of environment variables, is there some kind of a convention or "best practice" when it comes to grabbing environment variables and putting them into either a struct or a bunch of const's? Obviously, I want to fallback to a default value for each and every environment variable. Right now, using the f...