Home > Common Problem > body text

What are command line parameters?

藏色散人
Release: 2019-05-07 10:01:09
Original
4034 people have browsed it

The parameters given in the command line are the command line parameters. (That is, understood from the perspective of input location).

What are command line parameters?

Command line parameters

1. What are command line parameters?

For example: java Test1 365 156 "China"

(Test1 above must be the main class, otherwise it cannot run)

2. Who will receive the command line parameters?

A program begins with a call to the function main(). When doing this, two parameters are given to main(),

One of which describes the number of command line parameters, usually called argc; the other is an array of command line parameters, usually called argv.

The command line parameters are all strings, so the type of argv is char* [argc 1]. The name of the program is also passed in as argv[0],

so the value of argc is at least 1. This parameter list always ends with 0, that is, argv[argc]==0. [1]

3. What should you pay attention to when giving parameters on 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 quotes.

For example: java Test1 365 156 China "Beijing of China"

4. How to enter * (indicates multiplication) in the command line: If you enter * (multiplication) directly in the command line, The system will process it into several strings of the current path name. If you want * to represent multiplication, you should enter "*" or "*". After getting the string from args, use trim() to remove the spaces at both ends. Of course You can also enter "#*" and then find a way to remove the # in front, that is, as long as you do not enter * separately.

5. When Total Commander starts, you can use one or two folders as command line parameters. These folders are used to set up file windows on one or both sides. In this way, you can create multiple icons for Total Commander in the program or startup menu, and each Total Commander will open a different folder or even a compressed package after startup. And you can specify different ini files, not just the default wincmd.ini, so that different users on the same machine can have different settings.

The above is the detailed content of What are command line parameters?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!