Out of the constraints of a coding IDE, I’ve always written my main function like this:
int main(int argc, char* argv[])
But in IDEs where they start you off with a hello world type application structure to start you off, I’ve seen it written in different ways. For example in Xcode, it has argv as a constant:
int main(int argc, const char * argv[])
I’ve also seen people declare argv[] as a double pointer, which I can’t understand the reason to:
int main(int argc, char** argv)
Is there any standard or convention to how this is declared? Should I have a double pointer, or a constant?
Bonus question: should the asterisk denoting a pointer be placed just after the data type, just before the variable name or separated in the middle?
Is there any standard or convention to how this is declared? Should I have a double pointer, or a constant?
This is clearly defined in the C++ Standard.
Reference:
C++03 Section § 3.6.1:
Para 2: