For this assignment you will write a program called dogs.c
that uses
command line arguments to get the names of file to process, read
data from those files, and perform some trivial calculations.
                
Your program must run with one or more command-line arguments: the names of the files to process. Your program must ensure that at least one command-line argument is submitted to the program. If not, you must print an appropriate usage statement.                 
The data files you must process should contain several fields in each line: a dog breed name, a range of weights, and “lb”, which means pounds. For example:                 
Akita 75-120 lb Beagle 20.0-25.765 lb Bouvier 60-90 lb Bulldog 49-55 lb Cerberus 1000-2000 lb
Here’s another, less orderly but still valid, example:                 
Bullmastiff 100-133 lb Chihuahua 2-6 lb Collie 0000050.246813579-75 lb corgi 24-30 lb woof 17.7077887-18.7077887 lb Wh!pP3+ 25-45 lb
Your program must work on these files or other such files, no matter what their filenames are. It should print the breed name, range of weights in pounds, and the range of weights in kilograms. For the purpose of this assignment, there are 0.453 592 37 kg in a pound.                 
% cat dog-weights Dalmatian 55-55 lb Doberman 66-88 lb Maltese 6.5-9 lb Papillon 7-10 lb Beagle Pekingese 8-10 lb Beagle fish Beagle 10 Beagle 10- Beagle 10-fish Beagle 10-99 Beagle 10-99 fish Whippet 25-45 lb % c11 -Wall dogs.c % ./a.out dog-weights Dog Breed min(lb) max(lb) min(kg) max(kg) --------- ------- ------- ------- ------- Dalmatian 55.00 55.00 24.95 24.95 Doberman 66.00 88.00 29.94 39.92 Maltese 6.50 9.00 2.95 4.08 Papillon 7.00 10.00 3.18 4.54 ./a.out: Bad line 5 in dog-weights Pekingese 8.00 10.00 3.63 4.54 ./a.out: Bad line 7 in dog-weights ./a.out: Bad line 8 in dog-weights ./a.out: Bad line 9 in dog-weights ./a.out: Bad line 10 in dog-weights ./a.out: Bad line 11 in dog-weights ./a.out: Bad line 12 in dog-weights Whippet 25.00 45.00 11.34 20.41
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a
a.out
into your message.
char
constants for char
values, not int
ASCII values:
'A'
, not 65
.
~cs157/bin/checkin HW1 dogs.c
How to receive negative points:                 
User: Guest