i came across following in searches regarding environment variables in c:
int main (int argc, char *argv[], *char *envp[])
i have searched around , can't find conclusive regarding question.
what of available arguments main()
can accept?
the c99 , c11 draft standards allow implementation defined set of parameters main
, these parameters going specific systems(non-portable). section 5.1.2.2.1
:
[...]or in other implementation-defined manner[...]
the additional parameters can find documented envp
, apple
, can find description in wikipedia's c , c++ section on entry points:
other platform-dependent formats allowed c , c++ standards, except in c++ return type must int;[6] example, unix (though not posix.1) , microsoft windows have third argument giving program's environment, otherwise accessible through getenv in stdlib.h:
int main(int argc, char **argv, char **envp);
mac os x , darwin have fourth parameter containing arbitrary os-supplied information, such path executing binary:[7]
int main(int argc, char **argv, char **envp, char **apple);
it looks windows has microsoft specific wmain takes wchar_t
:
int wmain(int argc, wchar_t *argv[], wchar_t *envp[]);