I know that when programming in c++ I can access individual environment variables with getenv.
I also know that, in the os x terminal, I can list ALL of the current
Use the environ global variable. It is a null-terminated pointer to an array of strings in the format name=value. Here's a miniature clone of env:
#include
#include
extern char **environ;
int main(int argc, char **argv) {
for(char **current = environ; *current; current++) {
puts(*current);
}
return EXIT_SUCCESS;
}