3.14 COMMAND LINE ARGUMENTS
These days we run our programs from integrated development environments like TurboC++. They offer us various services. However, when we have a program in machine language form (.exe) file, we execute it from command line of our operating system (DOS, Windows, Linux, etc.) At that time, we can pass parameters to our programs. These parameters are termed as command line arguments. The C++ language has reserved keywords argc and argv for use in this situation. Variable argc stores the number of arguments passed. Variable argv is an array of strings. It stores the arguments as a string. Suppose we have a program cla1.exe, we can run it as:
Command Prompt> cla1 good morning <enter>
In this case, “good” and “morning” are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access