Command Line Arguments in C
Command Line Arguments
- The arguments passed from command line are called command line arguments. These arguments are handled by main() function.
- To support command line argument, you need to change the structure of main() function.
Syntax
argc counts the number of arguments. It counts the file name as the first argument.
The argv[] contains the total number of arguments. The first argument is always the file name.
Sample Code:
Output:
Learn C - C tutorial - Command Line Argument - C examples - C programs