CSCI 112
Lab 6 - Multiple File Compilation


Objectives:


Readings:


Deliverables: (DUE BY MIDNIGHT ON 02/24/2013)


TO DO (for today's lab)


Helpful Hints (I put graphics below, so you would not just copy this stuff...)


Declaring prototypes in a header file

I like to put all my prototypes in a separate file (here, I called it proto.h) and then to include this file in my main program (#include “./proto.h). When you do it this way, you may need some additional pre-processor directives to avoid duplications of your declarations (just to play it safe...). This time, file proto.h should include prototypes of all functions mentioned in your textbook (p. 322). Here is a sample proto.h file (I included pre-processor directives to avoid accidental duplications of my functions' prototypes):

wpe3


Linking the source files

OK, so here is an example of what you want to do (using your Makefile):

wpeD

And here is how you can get there:

wpeE

References to proto.h in the Makefile can be omitted, if you included it as I mentioned above. Repetitions do not bother us, since we used Conditional Compilation in our header file. 


Testing the program

You can test your program by controlling it from your screen and keyboard. For a test run of only problem 4 you can enter:
4
1000
25
5
The above data should produce the following results.
The rate in milliliters per hour is 40.

You can also write test files (with job selections and relevant data entries) and use input redirection. For instance if you enter to test numbers to your test file as presented on the left-hand side of the figure below, you can simulate some cases, as presented on the right-hand side of the figure.

wpeF

To perform automatically more detailed tests, you can redirect BOTH input and output (type: lab6 < MyInput > MyOutput). MyOutput will NOT have the responses to the input prompts, just the prompts all run together.


Formatting the output 

There will be quite a few prompts coming out of your program. You will need to have them formatted exactly as shown in the text to be sure that our tests script run properly. I know it is a pain, but it speeds up the grading significantly so we are stuck with it. The following are two sample outputs. The first is with normal blanks, and the second is with the long strings of blanks replaced by small b's. This should help you count the spacing of the expected output. I try to post more examples here shortly... Make sure you match the outputs exactly! Good luck!

INTRAVENOUS RATE ASSISTANT
Enter the number of the problem you wish to solve.
    GIVEN A MEDICAL ORDER IN                CALCULATE RATE IN
(1) ml/hr & tubing drop factor              drops / min
(2) 1 L for n hr                            ml / hr
(3) mg/kg/hr & concentration in mg/ml       ml / hr
(4) units/hr & concentration in units/ml    ml / hr
(5) QUIT

INTRAVENOUS RATE ASSISTANT
Enter the number of the problem you wish to solve.
bbbbGIVEN A MEDICAL ORDER INbbbbbbbbbbbbbbbbCALCULATE RATE IN
(1) ml/hr & tubing drop factorbbbbbbbbbbbbbbdrops / min
(2) 1 L for n hrbbbbbbbbbbbbbbbbbbbbbbbbbbbbml / hr
(3) mg/kg/hr & concentration in mg/mlbbbbbbbml / hr
(4) units/hr & concentration in units/mlbbbbml / hr
(5) QUIT

Here are some results I got, maybe you will find it useful when programming:

wpeG-LAB6