Property of Penn Engineering MCIT 593 - Introduction to Computer Systems argc and argv The two default arguments to main recall C’s roots in Unix. They are used to pass command line arguments to a program. • int main (int argc, char **argv) • argc – number of ‘words’ on the command line (argc >= 1) • argv – list of strings containing all of these words • Note the declaration of argv as a pointer to an array of pointers – double dereferencing. Example: int main (int argc, char **argv) { int i; for (i = 0; i < argc; ++i) printf ("Argument %d = %s\n", i, argv[i]); } 1
学霸联盟