What is the point of using this:
int main(argc,argv[])
instead of using plain and simple int main()
Thanx for ur time.
What is the point of using this:
int main(argc,argv[])
instead of using plain and simple int main()
Thanx for ur time.
It allows you to send command line arguments to the program.
So you could do something like this
"myprog.exe command1 options"
instead of asking the user inside the function what command / options they want to use
and the correct syntax is
int argv, char ** argc
or
int argv, char * argc[]
either way gets compiled the same, the int argv tells you how many strings are in argc, so if you did this
"myprog.exe one two three"
argv = 4
argc[0] = "myprog.exe" with a \0 at the end
argc[1] = "one"
argv[2] = "two"
argv[3] = "three" all string have \0 appended to the end
and you can call the variables whatever you want to, it just makes it easier for everyone else to read if you stick to the standard names
You meanand the correct syntax is
int argv, char ** argc
or
int argv, char * argc[]
int main(int argc, char *argv[])
or
int main(int argc, char **argv)