Home > Back-end >  C language, how to bring the wide string passed to the main function
C language, how to bring the wide string passed to the main function

Time:12-28

You know the definition of the main function for the int main (int arg c, char * * argv), did not int main (int arg c, would be * * argv) version of the main function, how to give wide string as a parameter to the main function? Practice directly seems to also won't go wrong, it really is how to do? Hope the great god,

CodePudding user response:

Parameters of the main function, usually written as this format: main (int arg c, char * argv []), the first parameter arg c is an integer variables, the second parameter argv is an array pointer, the main () function is made up of a system call, he is two parameters from the command line contains the command name and need to the parameters of the main function, general form is: the command name parameters 1 2... Parameter n, the main function of parameter passing laws, the main function of the first parameter arg c refers to the number of parameters in the command line, which indicates that the command line string total number (such as: the command name parameters 1, 2, then arg c=3), the command line the first string "command name" address to the pointer array argv [0], namely argv [0] points to the string "command name," argv [1] points to the string "parameter 1, argv [2] points to the string" parameter 2 "and so on, char * argv [] is a pointer array, using pointer array as a parameter of the main function, can send command line arguments to the program (these parameters are strings), these do not know the length of the string, the parameters and the length of the string is not the same, the number of command line parameters can be arbitrary,

CodePudding user response:

Should be start RTL code calls the main before parsing the command line parameters, to compile option is unicode or ANSI, do the corresponding transformation and then passed on to the main
  • Related