/* Printing out the command line arguments */ #includeint main (int argc, char *argv[]) { int i; printf("Number of arguments is %d\n", argc - 1); for (i = 1; i < argc; ++i) { printf("%s ", argv[i]); } printf("\n%s is exiting\n", argv[0]); return 0; }
If the above program is compiled into an executable called
blah and we run the command blah foo bar baz
, we get
the output:
Number of arguments is 3 foo bar baz blah is exiting