Please tell us about how the
argv arguments work in C / C ++ .
argvis an array of pointers to null-terminated strings containing the command line options your program was invoked with.
argcgreater than zero, then
argvcontains a pointer to the name of your program. How this name is presented is implementation dependent. If no program name is supplied,
argvwill point to an empty string (that is, it cannot be a null pointer).
argcgreater than one, then
argv[argc - 1]contain pointers to command line parameters .
The size of this array is
argc + 1(not
argc, as is often mistakenly believed). This ensures that
argv[argc]contains a null pointer. Thus, to find the end of the
argvarray, you can either use the
argcvalue, or simply browse the
argvarray until you encounter the first null pointer.
In the C language, it is allowed to modify both the elements of the
argvarray and the strings themselves indicated by the elements of the
argvarray (of course, within the original string length). C ++ does not explicitly grant this permission.