What are the arguments passed into the main method of a command-line program:
int main(int argc, const char * argv[])
what is the first int mea
argc
means "argument count". It signifies how many arguments are being passed into the executable.
argv
means "argument values". It is a pointer to an array of characters. Or to think about it in another way, it is an array of C strings (since C strings are just arrays of characters).
So if you have a program "foo" and execute it like this:
foo -bar baz -theAnswer 42
Then in your main()
function, argc
will be 5, and argv
will be:
argv[0] = "/full/path/to/foo";
argv[1] = "-bar";
argv[2] = "baz";
argv[3] = "-theAnswer";
argv[4] = "42";