Hello AlexPlanks,
Starting at the top:
Note that line does not start with "/*", so everything that follows ia not a comment.
Line 10 is wrong. The instructions say it should be
int GetLeast(ifstream, int);
. The "ifstream" is being passed by value not by reference as instructed. And the second parameter is optional.
When you compare lines 10, 33 and 79 all need to match and they do not. The prototype and the function both have two parameters, but the function definition only has one parameter.
Lines 10 and 79 need to match both in the return value, which is correct, and in the parameters which do not match.
Line 33. The function call returns a value that you never make use of, so on line 40 "smallestValue" still has the value of "INT_MAX".
For the function "GetLeast" the instructions say define two variables which you have done. I would suggest initializing all the variables in the program when they are defined. Line 82 should be initialized to "INT_MAX". Defining the two variables inside the function tends to negate the need for a second parameter in the function definition because the return value will take care of what you need.
Line 84 is redundant and will skip using the first number read. The while loop is all you need.
Inside the while you will need to:
- Test to see if the new value is smaller than the lowest read so far
If yes, save the new value to the lowest so far variable |
Short of having an input file to work with I will have to fix the problems and come up with an input file to test it.
Hope that helps,
Andy