argc? argv ?
In main function, there are two parameters, argc and argv. int main( int argc, char **argv) argc := argument count, which is the number of parameters. argv := argument value, which assign by terminal from user. argv[0] := the name of this program argv[1], argv[2] := enter by user
Test:
1
#include <stdio.h>
2
​
3
int main( int argc, char **argv ){
4
int i = 0;
5
printf( "argc = %d\n", argc);
6
for( i=0; i!=argc; ++i){
7
printf( "argv[%d] = %s\n", i, argv[i] );
8
}
9
return 0;
10
}
Copied!
​
Copy link