So, while we could give alternate names for the argc and argvparameter names, we will use these two names throughout this chapter for consistency.
When we invoke a program, we now see the following:
- Memory is allocated in program space.
- Command-line arguments are processed into function parameters passed into main() or ignored if those parameters are absent.
- The execution begins with a call to main().
The first thing to note is that every argument from the command line is broken up into strings. A pointer to the beginning of each string is placed in argv, and argcarray is incremented. In many cases, string input is sufficient without any further processing. We will explore converting string input into other values in the next chapter, Chapter 21, Exploring Formatted Input.
The program name itself is always placed in argv[0]. Therefore, argc will always be at least 1.
Each argument...