Arguments for Main

This tip submitted by Sajan on 2010-07-06 11:23:55. It has been viewed 10413 times.
Rating of 4.5 with 71 votes



On Windows and Unix, the main function can actually accept 3 parameter! Third parameter, envp, is an array of environment variables:

int main(int argc, char **argv, char **envp);


On OS X, there is a fourth argument that supplies arbitrary information from the OS (such as the program path):

int main(int argc, char **argv, char **envp, char **apple);




More tips

Help your fellow programmers! Add a tip!