Hello DashMGJ,
Thank you for the input file. It is a big kelp.
The "loadData" function is better, but still not right.The function definition on line 51 still looks like a proto type not a function definition. It should be:
void loadData(ifstream & inFile, Temperature arrayName[], int & size)
. Where "arrayName" is the array you have not defined yet. Inside the function "myTemps" is not an array, but a single object of the struct. This will not work and should have given you compile errors.
Line 36 is a prototype not a function call. It should be:
loadData(inFile, arrayName, size);
. Just the names are needed. Try reading this:
http://www.cplusplus.com/doc/tutorial/functions/
For the other two functions they are set up to return an entire struct. This is over kill when all you need it to return an index to the array you need to define in main. You will need to change the return value of "Temperature" to "int" and then use "index1" and "index2" to receive the return values of the functions. Using "index1" and "index2" you can access the array to print the highest and lowest temps and the month that they are in.
The code for "averageHigh" is mostly correct except you are using the variable with "myTemps". "myTemps" is not an array. The same for "averageLow" function.
In the "agerageLow" function setting "lowest to zero to start with will be a problem. What happens when none of your low temps are below zero? I like to set this variable to a number higher than anything you would expect to find in the low temps. I used "100" in my version.
Lines 60 and 74 are the wrong way to write the function definition and you are using variables in the parameters you do not need. "highest" and "lowest" should be defined in the function not the parameters. Just as an idea this is the function definition that I used:
int AverageLow(Temperature temps[], int size)
. "size" does not need to be passed by reference because the function should not ever change this variable. The better definition would be:
int AverageLow(Temperature temps[], const int size)
. Since you are only using "size" not changing it.
In main you have defined all the numeric variables as doubles. Only "avgerge1" and "averge2", if ever used need to be a double. All the other variables would be fine as "int"s.
Line 26 defines and opens the file stream. After that you should check that the file has been opened before trying to use it.
You still need to define an array of structs in main.
Hope that helps,
Andy
Edit: My apologies I finally noticed where you did make an array of "myTemps". I was not expecting it where you defined it. I will have to try your new code to see how it works.