In a program the most significant function is the main() function. It is defined with a return type of int and without arguments
/* … */
Command-line arguments are typically the arguments given to the main function.It includes two arguments the first argument is the number of command line arguments and second is list of command-line arguments.
int main(int argc, char *argv)
/* … */
argc (argumented Count)-> is of type integer and includes the count of number of arguments including the program name.Therefore if we pass a single argument,the count of argc will be 2 (one for argument and one for program name).The value of the count cannot be negative.
argv (argumented Vector)->is array of character pointers listing all the arguments.
Properties of Command Line Arguments:
These arguments passed to main() function.
These are parameters/arguments supplied to the program when it is
- argv[argc] is a NULL pointer.
- argv holds the name of the program.
- argv points to the first command line
- argument and argv[n] points last argument.
Note : Command-line arguments are separated by a space, but if the argument itself is space then we should pass such arguments by putting them inside double quotes ” or single quotes ”.