![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Now that you know how to supply a command-line file name, you probably want to know how to supply other command-line arguments as well. In particular, you probably will want to know how to supply and make use of command-line arguments that determine exactly what your program is to do, given several slightly different options.
Suppose, for example, that you want a version of analyze_trades
that
examines a specified trade file, computing either the average
price-per-share paid, or the average number of shares traded, or both.
Following the conventions of Unix, you probably would want your program
to accept an option-specifying character called a
flag, marked as
such by a hyphen. You would want your program to recognize the following
indication that it is to compute average price:
*-- Indicates program is to compute average price v analyze_trades -p test.data
Similarly, your program should recognize the following indication that it is to compute the average number of shares traded:
*-- Indicates program is to compute average number | v analyze_trades -n test.data