Command Line Parameters

Source: Internet
Author: User
Command Line Parameter 1. What is a command line parameter? Literal understanding: the parameter given in the command line is the command line parameter. (From the perspective of the input position) the given parameters when loading the main class. (The class with the main method is called the main class, and the command line parameters are sent to the main method, so you can also say that the command line parameters are sent to the main method parameter ). For example, Java test1 365 156 "China" (The above test1 must be the primary class, otherwise it cannot be run) 2. who receives the command line parameters? A program starts calling the main () function. In this case, two parameters are sent to main (), one of which describes the number of command line parameters, usually called argc; the other is the array of command line parameters, it is usually called argv. The command line parameters are all strings, so the argv type is char * [argc + 1]. The program name is also passed in as argv [0], so the argc value is at least 1. The table with this parameter always ends with 0, that is, argv [argc] = 0. [1] 3. What should I pay attention to when specifying parameters in the command line? Command line parameters are separated by spaces. However, if the command line parameter itself contains spaces, the parameter must be enclosed in a pair of double quotation marks. For example, Java test1 365 156 China "Beijing of China" 4. Enter * (representing multiplication) in the command line: If you enter * (multiplication) directly in the command line ), the system processes several strings of the current path name. To * represent multiplication, enter "*" or "*". ARGs obtains the string and uses trim () remove the spaces at both ends. Of course, you can also enter "# *" and try again to remove the preceding #, that is, you only need to enter * separately. 5. When total commander is started, one or two folders can be used as command line parameters. These folders are used to set file windows on one or both sides. In this way, you can create multiple icons for total commander in the program or Startup menu. After each total commander is started, open different folders or even compressed packages. In addition, you can specify different INI files, not only the default wincmd. ini files, so that different users on the same machine can have different settings. Syntax: totalw..exe [/o] [/n] [drive1: \ directory1 [drive2: \ directory2] [/I = Name. INI] [/F = ftpname. INI] Or: totalw..exe [/o] [/n] [/L = drive1: \ directory1] [/r = drive2: \ directory2] [/I = Name. INI] [/F = ftpname. INI] Options for adding command-line parameter to the prompt command (instead of the Window environment. [In other words, the parameter is included when the program is run in the command line mode.] For example, in command ARP-a,-A is a parameter of command arp. For example, fcopy.exe is an executable program file that implements file replication. Run fcopy in the command line format:
C: \ TC20> fcopy in. dat out. in dat, "C: \ TC20>" is the system prompt and "fcopy in. dat out. dat "is the input command to make the computer in c: \ TC20. copy the DAT file to c: \ TC20. DAT file. "In. dat" and "Out. dat" are command line parameters, and can contain drive letters and search paths before "in. dat" and "Out. dat. When the program is running, the operating system passes the command line parameter to the form parameter of the main function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.