I ran into a function like this earlier:
int main(int argc, char **argv, char **argw){
}
Why is there a need for three arguments, and how does this actually work?
I ran into a function like this earlier:
int main(int argc, char **argv, char **argw){
}
Why is there a need for three arguments, and how does this actually work?
The third argument to main is normally called envp.
int main(int argc, char **argv, char **envp) {
Many compilers provide a third argument to main, but it is not specified in the C standard, so using it is undefined behaviour. If you try to port the code to a platform that doesn't provide a third parameter the program will most likely fail.
I've seen these arguments before. My compiler places them there as well when starting in C++ code. I can tell you for a fact that they are not necessary in C++, although I can't say for sure in C. They look to be slots for a variables to be passed in to the function int main. One of type int, and two of type char. These variables would be passed in, generally by the user at the time the program is executed.