In C, this is used to provide information about arguments.
where argc is the argument counter represents the number of arguments
argv is argument vector represents a list (array) of multiple arguments, so it is [] .
These parameters are of type string, so they are of type char pointers.
argv[0] the full pathname when the program runs.
argv[1] represents the first parameter.
hello.c
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char const *argv[]) { printf("The number of parameters:%d\n",argc); printf("Program path:%s\n",argv[0]); printf("the first parameter:%s\n",argv[1]); return 0; }
run it:
C:\Users\Administrator> cd C:\ C:> hello.exe lautturi
The number of parameters:2 Program path:C:\hello.exe the first parameter:lautturi