![]() When the above code is compiled and executed with a two arguments, it produces the following result. When the above code is compiled and executed with single argument, it produces the following result. Printf("Too many arguments supplied.\n") Printf("The argument supplied is %s\n", argv) Following is a simple example which checks if there is any argument supplied from the command line and take action accordingly − The command line arguments are handled using main() function arguments where argc refers to the number of arguments passed, and argv is a pointer array which points to each argument passed to the program. These values are called command line arguments and many times they are important for your program especially when you want to control your program from outside instead of hard coding those values inside the code. It is possible to pass some values from the command line to your C programs when they are executed.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |