0% found this document useful (0 votes)
12 views2 pages

Command line arguments

command line argument

Uploaded by

Babin Bista
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Command line arguments

command line argument

Uploaded by

Babin Bista
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Command line arguments

Command-line arguments are used in programming to pass information to a program at the time of
execution. This makes programs more flexible and versatile, allowing users to input values or options
directly when starting the program rather than hard-coding them or requiring input from the user after
the program has begun.

Command line argument is an important concept in C programming. It is mostly used when you need to
control your program from outside. In C, command line arguments are passed to the main() method.

When the main function of a program contains arguments, then these arguments are known as Command
Line Arguments.

The main function can be created with two methods: first with no parameters (void) and second with two
parameters. The parameters are argc and argv, where argc is an integer and the argv is a list of command
line arguments.

argc denotes the number of arguments given, while argv[] is a pointer array pointing to each parameter
passed to the program. If no argument is given, the value of argc will be 1.

Properties:

Command line arguments in C are passed to the main function as argc and argv.

Command line arguments are used to control the program from the outside.

Command-line arguments are useful when you want to control your program from outside rather than
hard coding the values inside the code.

Example of command line argument in C

You might also like