January 2015
Intermediate to advanced
96 pages
1h 20m
English
CHAPTER 20
![]()
Command Line Arguments
When a C program is executed it can accept arguments that are passed to it from the command line. These command line arguments are useful for controlling the behavior of the program from outside the code. The arguments are passed to the main function, which is then set to accept two parameters as shown here.
int main(int argc, char* argv[]) {}
The integer argc is the number of arguments passed, and argv is a pointer array to the supplied command line arguments. The first argument argv[0] is the name of the program, so the argument count in argc begins with 1 when no arguments are passed. If the program name is ...
Read now
Unlock full access