Command Line Arguments

It is possible to pass values from command line to Your C programs when they are executed. This is very important when you want control your program from outside instead of hard coding these values inside the program.

Command Line arguments are handled using main() function.
main(int argc,char *argv[])

argc: number of arguments passed to the program.
argv[]: is a pointer array which points to the each argument passed to the program.

argv[0] holds the name of the program itself.

argv[1] holds the first argument.

No comments:

Post a Comment