Home Segments Index Top Previous Next

606: Mainline

More specifically, to iterate over the command-line arguments, you can use the following for statement, which increments a counter, argument_counter, and runs the loop for values of argument_counter ranging from 1 to 2 less than the value of argument_count:

for (argument_counter = 1; 
     argument_counter < argument_count - 1; 
     ++argument_counter) ... 

You do not run the loop with argument_counter equal to 0, because the first character string is the name of the program, rather than a flag argument; similarly, you do not run the loop with argument_counter equal to 1 less than the value of argument_count, because the final argument is file-specifying character string, rather than a flag argument.