PDA

View Full Version : The difference between int main() and int main(int argc, char* argv[ ])



rezas1000
8th August 2014, 09:42
Hi!
What difference is there between int main() and int main(int argc,char* argv[ ])?


Why are arguments such as argc or argv[ ]?

Thanks

Lesiok
8th August 2014, 10:23
Base of C/C++ : look here (http://stackoverflow.com/questions/3898021/mainint-argc-char-argv)

ntzrmtthihu777
8th August 2014, 19:08
short answer, int main() can't take command line arguements, while int main(int argc, char* argv[]) (or char **argv) can. argc is a count of arguements, which includes the executable name itself, so `nano foo` has argc of 2, nano and foo, and you would access those via argv[0] and argv[1] respectively.