I was just curious, but since the prototype of main can be
int main(void) or int main(int argc, char *argv[])
is there a main.h or how is this being taken care of? And can you change these parameters?
I was just curious, but since the prototype of main can be
int main(void) or int main(int argc, char *argv[])
is there a main.h or how is this being taken care of? And can you change these parameters?
It is more like those can be the return type and signature of the main function. You do not actually write a prototype for it. You can certainly use your own parameter names if you prefer, and depending on the (compiler) implementation more parameters may be available.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
but i thought parameters for a function were declared in the prototype of the function and the return type is what is infront of the function name, so the return type is always int?
They are, if you wish to provide the prototype and later (or in another place) define the function. But the main function is usually defined without a prototype, since it is not usually called from within the program.Originally Posted by boxden
Yes, though there are exceptions that you need not worry about.Originally Posted by boxden
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)