When a program is started, it can be started with or without arguments. These arguments are normally fed in as parameters when the program is called. A simple example of this is starting the manual application (found on many BSD and Linux machines):
man ffmpeg
In the preceding statement, man
is the name of the program or script to be called with the argument ffmpeg
. Similarly, take a look at the following example for Windows users:
Notepad
is the program name with the first argument being the file to read in (in this example, the file doesn't exist, so the UI asks if you wish to create it).
It is not uncommon for one program to load another program to perform a task.
In C, the parameter list for main is given as follows:
int main(int argc, char *argv[])
argc
is the maximum number of arguments with argv
holding the arguments. Here, the program name is argv[0]
, so all additional arguments start at 1.
Rust's main
takes no arguments like this. Command-line parameters are available...