You can use the envp argument for main :
int main(int argc,char* argv[], char** envp)
and as a bonus, apparently on OSX you have apple , which gives you other information provided by the OS:
int main(int argc, char **argv, char **envp, char **apple)
But what is it used for? Well, Apple can use the apple vector to pass any βhiddenβ parameters that they want for any program. And they really use it. Currently apple [0] contains the path where the executable binary was found on disk. What are you saying? How is apple [0] different from argv [0]? The difference is that argv [0] can be set to any arbitrary value when execve (2) is called. For example, shells often distinguish an input shell from a regular shell by launching an input shell with the first character in argv [0], which is a -
source share