Finally, your program should handle errors gracefully. For example, if the command line arguments are supposed to be files, and the user specifies a non-file, you should print a descriptive error message on standard error, and either exit or not exit as you see fit.
calcavg [ -c n ] [ files ]If files are specified, then calcavg works on all files. If no files are specified, then calcavg works on standard input. Without the -c option, calcavg treats every word of its input as a number, and prints out the average of all the numbers. If -c is specified, then it only averages numbers in column n (where 1 is the first column, unlike sort). If there are fewer than n columns on a line, then that line is ignored. If multiple files are specified, then calcavg calculates one average for all the files, not one average per file.
golfer-name -- scoreGolfer names can be any number of words. The score file should not be assumed to be sorted. If the score is ``missed cut'' then the golfer did not finish the tournament. Examples of score files are usopen and masters.
Your job is to format the output better. You need to print one line per golfer, where each line is: the golfer's name padded to 25 spaces, the golfer's score (use ``missed'' if the golfer missed the cut), and the number of strokes above the best golfer's score. If a golfer missed the cut, then his last column should be the maximum number of strokes above the best golfer's score, plus one. (Note, low score is good in golf). Finally, the output should be sorted by score, with the cut missers printed last.
You should see the example program for an example of how output should look.
Here's a hint, for those who want one.
The relevant lines in an input file are:
That's all you need. Go to it, and make sure that it works for all of the above input files. Try the example to see what the output should look like.