Debugging problem

Well the program is simple enough, I'm taking a list of numbers from a file, then finding the average, lowest, highest, ect.. however this compiler error is getting to me, here's the code:

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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include<iostream>
#include<string>
#include<fstream>
#include<cstring>
#include <cstdlib>
using namespace std;

int average_temp(int nums[], int index);
int highest_temp(int nums[], int index);
int lowest_temp(int nums[], int index);
int temp_85(int nums[], int index);
void convert_celsius(int nums[], int index);


int main()
{
	ifstream inputFile;
	string filename;
    
    const int SIZE = 100;
	int array [SIZE];
	int count = 0; 

	int highest, lowest, greater_85, average;
	


	cout << "Enter the filename: ";
	cin >> filename;

	inputFile.open (filename.c_str());

	if (inputFile)
	{
		while(count < SIZE && inputFile >> array[count])
			count++;
			
		for(int i = 0; i <= count; i++)
			cout << array[i] << endl;
		
	}

	else 
	{
		cout << "Error opening the file.\n";
		return 0;
	}



			
	inputFile.close();



	cout << "They're are " << count << " values representing temperatures\n";
	cout << " in the file." << endl;

	average = average_temp(array, count);
	cout << "The average temperature is: " << average << endl;
	
	highest = highest_temp(array, count);
	cout << "The highest temperature is: " << highest << endl;
	
	lowest = lowest_temp(array, count);
	cout << "The lowest temperature is: " << lowest << endl;

	greater_85 = temp_85(array, count);
	cout << "They're are " << greater_85 << " temperatures over 85 degrees\n.";

	convert_celsius(array, count);



		
	
	
	return 0;
}

	


int average_temp(const int nums[], int index)
{
	int sum, average;


	for(int a = 0; a < index; a++)
	{
		sum += nums[a];
	}

	average = sum / index;

	return average;
}

int highest_temp(const int nums[], int index)
{
	int highest = 0;

	for(int b = 0; b < index; b++)
	{
		if(nums[b] > highest)
			highest = nums[b];
	}
	return highest;
}

int lowest_temp(const int nums[], int index)
{
	int lowest = 0;

	for(int c = 0; c < index; c++)
	{
		if(nums[c] < lowest) 
			lowest = nums[c];
	}
	return lowest;
}

int temp_85(const int nums[], int index)
{
	int counter = 0;

	for(int d = 0; d < index; d++)
	{
		if(nums[d] > 85)
			counter++;
	}
	return counter;
}

void convert_celsius(const int nums[], int index)
{
	ofstream outputFile;
	outputFile.open ("celsius.txt");
	int new_array [index];

	for(int e = 0; e < index; e++)
	{
		new_array[e] = (nums[e] - 32) * (5/9);
		outputFile << new_array[e];
	}

	outputFile.close();

	cout << "You're temperatures have been converted from Fahrenheit to Celsius.\n";
	cout << "The new values have been saved to file celsius.txt." << endl;
	
}


and the compiler error:

g++ temperature.cpp -o run
/tmp/cc0iLw2O.o: In function `main':
temperature.cpp:(.text+0x4d2): undefined reference to `average_temp(int*, int)'
temperature.cpp:(.text+0x51f): undefined reference to `highest_temp(int*, int)'
temperature.cpp:(.text+0x56c): undefined reference to `lowest_temp(int*, int)'
temperature.cpp:(.text+0x5b9): undefined reference to `temp_85(int*, int)'
temperature.cpp:(.text+0x606): undefined reference to `convert_celsius(int*, int)'
collect2: ld returned 1 exit status

any ideas? thanks!
simple: change from
1
2
3
4
5
int average_temp(int nums[], int index);
int highest_temp(int nums[], int index);
int lowest_temp(int nums[], int index);
int temp_85(int nums[], int index);
void convert_celsius(int nums[], int index)
to
1
2
3
4
5
int average_temp(const int nums[], int index);
int highest_temp(const int nums[], int index);
int lowest_temp(const int nums[], int index);
int temp_85(const int nums[], int index);
void convert_celsius(const int nums[], int index);
Thanks man that did it! It's always the little mistakes that take the longest.
Topic archived. No new replies allowed.