Observance of the whereabouts of the 100th article,,,Although the content is somewhat illegible
Yesterday, see route on the main (int argc,char *argv[]) The article feels written brief said such a function
Of course first contact functions of this function is not the main (int argc,char *argv[]) But the main (int AC, char * of[])
They use the same。
Every c program must have a main function,As the beginning of program。When a program is executed,Command line parameters (resolved via the shell) provided through two main functions,First int type (argc, or AC) represents the number of command line parameters。Second char pointer of type array parameters (*AV[]Or *argv[]) Is a pointer to a command line argument array。And (*AV[]Or *argv[]) List ends with NULL for the pointer in argv [argc]For NULL
Here a small program to increase your understanding of this
1 2 3 4 5 6 7 8 9 10 11 12 |
/* test of int main(int ac,char *av[]) * * * */ #include<stdio.h> #include<stdlib.h> int main (int ac, char *av[]) { for(;ac != 0;ac--) printf("%s",av[ac]); } |
Original article written by LogStudio:R0uter's Blog » main (int ac, char * of[])和 main(int argc,char *argv[]) Of some of my understanding
Reproduced Please keep the source and description link:https://www.logcg.com/archives/502.html
In fact, the name can be taken lightly,You can even do this (C only)
int main(gc, gv)
int gc;
char ** gv[];
{
}
Actually do not write type?
This article is a friend of the hair,Very old friends。