Min and Max temps Array of Structs

Hey all,
I need to get this program to output the highest and lowest temperatures and the months that correspond from a text file.
Please help?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <istream>
using namespace std;

//struct data type - Temperature
struct Temperature
{
	string month;
	int highTemp;
	int lowTemp;
};

//function prototypes
void loadData(ifstream & inFile, Temperature temps[], int &size);
int averageHigh(Temperature temps[], int highest, int index1);
int averageLow(Temperature temps[], int lowest, int index2);


int main()
{
	Temperature temps[12];
	ifstream inFile ("temps.txt");

	//variables
	int highest = 0;
	int lowest = 0;
	int index2 = 0;
	int index1 = 0;
	int size{};
	
	loadData(inFile, temps, size);
	
	averageHigh(temps, highest, index1);
	cout << "The hottest month this year was " << temps[index1].month << " with a temperature of " << temps[index1].highTemp << endl;

	averageLow(temps, lowest, index2);
	cout << "The coldest month this year was " << temps[index2].month << " with a temperature of " << temps[index2].lowTemp << endl;

	//end program
	cin.ignore(100, '\n');
	cout << "Press any key to continue: " << endl;
	getchar();
	return 0;
}

void loadData(ifstream & inFile, Temperature temps[], int &size)
{
	while (inFile >> temps[size].month)
	{
		inFile >> temps[size].highTemp >> temps[size].lowTemp;
		cout << "loadData loop "<< size << endl;
		size++;
		cout << temps[size].highTemp << endl;
	}
}

int averageHigh(Temperature temps[], int highest, int index1)
{
	for (int i = 0; i < 12; i++)
	{
		if (temps[i].highTemp > highest)
		{
			highest = temps[i].highTemp;
			index1 = i;
		}
		return index1;
	}
}

int averageLow(Temperature temps[], int lowest, int index2)
{
	
	for (int i = 0; i < 12; i++)
	{
		
		if (temps[i].lowTemp < lowest)
		{
			lowest = temps[i].lowTemp;
			index2 = i;
		}
		return index2;
	}
}


Here is the text file:

1
2
3
4
5
6
7
8
9
10
11
12
13
January 47 36
February 51 37
March 57  39
April 62 43
May 69 48
June 73 52
July 81 56
August 81 57
September 75 52
October 64 46
November 52 41
December 45 35
Do not doublepost. You do already have a thread on this program: http://www.cplusplus.com/forum/beginner/226483/
Topic archived. No new replies allowed.