Command line argument
In most of c++ books I have found arg as
Is it necessary that int variable name must be argc only and char* name must be argv only. Though on Turbo c++(3) I am able to use any name but I suspect that it should only be argc and argv.
int main(int argc,char * argv)
I don't think so.
I did a test, and you can name them whatever you like. I guess it's just convention.
Call them whatever you want, but you're sure to attract comments if you defy this particular convention.
one more ques.
What will be output and why?
if command line arg is
int main(int argc,char* argv,char* env)
myprog.exe one two three
It wont compile in the first place due to a syntax error. Other than that it probably depends on your system, since the C++ standard doesnt specify what the additional arguments to main() should be (besides argc and argv).
Assuming your run-time passes a third argument to main() called envp, you should note that argc doesn't count how many environment variables you have.
for ( i = 0 ; envp[i] != NULL ; i++ )
Is how you step through it.