tags: c++
int main(int argc, const char** argv)Write a simple print program to see
#include <iostream>
using namespace std;
int main(int argc, const char** argv)
{
int i ;
for (i = 0; i<argc; i++)
cout<<argv[i]<<endl;
cin>>i;
return 0;
}
Compile in the command line, see the result
C:\Users\Desktop>g++ 716.cpp
C:\Users\Desktop>a.exe 778 666 999
a.exe
778
666
999
So you can seeargc Is the number of parameters input after you execute the file + 1
+1 is becauseThe default first parameter is the name of the file
argv Is it a chasettion of a char *, where the plot points to the pointer to the parameter variable
// main function can have two parameters, one is argc, argv a // C language provides only two main function parameters // The first parameter is a function of the number of parameters captured // seco...
int main(int argc, char * argv[]) { …… } c:count v: vector (vector array) Parameters argcWhen you start the program on behalf of, the number of command line arg...
"Int argc, char * argv []" parameter passed in the form of the main function "Int argc", argc is an integer data argc is "arguments count" abbreviation; It means paramete...
argc command line parameter is the number of total the argv [] argc of parameters, parameter 0 is the full name of the program, after the command line parameters with the parameter input by the user l...
1. Explanation of parameter meaning The argc and argv parameters are useful when compiling programs on the command line. main( int argc, char* argv[], char **env ) in: The first parameter, int-type ar...
int main(int argc, char* argv[]) argc indicates the number of terminal input parameters, including the file name (automatically obtain the value) argv is a string pointer, which stores all input comma...
One "Int" needless to say, it is the return type of the main function. Generally speaking, sequential execution returns 0 and error returns 1, but for the main function, the return value is ...
argc: The total number of parameters on the command line, that is, the format of the elements in argv. *argv[ ]: String array, used to store an array of pointers to your string parameters, each elemen...
int main(int argc, char* argv[ ]) allows parameters to be written during execution. This format is fixed. (1) The C language stipulates that the main function can only have two parameters. It also sti...
The main function with formal parameters, such as main( int argc, char* argv[], char **env ), is the standard way of writing the main function of C/C++ in UNIX, Linux, and Mac OS operating systems, an...