Issue with struct array program

Hello!!! Im posting this because im having an issue with my program, see below. The problem im having are errors with my function calls saying the compiler cant convert my functions to the arguments in my function definitions after my return 0; statement. I think the rest of my code should work, but I dont know what to do about the errors.Fairly new to C++, so excuse my mistakes. Thanks for any help that can be provided, and thanks for your time.



#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

const int size = 12;

struct cyclistType
{
string cyclistL;
int cyclistNum;
int milesRidden;
};
cyclistType cyclistInfo[size];
void fillArray(cyclistType cyclistInfo[size]);
void printArray(cyclistType cyclistInfo[size]);
void totalMiles(cyclistType cyclistInfo[size], int total);
void mostMiles(cyclistType cyclistInfo[size]);

int main()
{

int total;
int max;

fillArray(cyclistInfo[size]);
printArray(cyclistInfo[size]);
totalMiles(cyclistInfo[size], total);
mostMiles(cyclistInfo[size], max);

system("pause");

return 0;
}
void fillArray(cyclistType cyclistInfo[size])//Function to fill array.
{
int i;
for(i=0; i<12; i++)
{
cout <<"Please enter the cyclist's last name, cyclist number, and how many";
cout <<"miles they have ridden :" << endl;
cin >> cyclistInfo[i].cyclistL >> cyclistInfo[i].cyclistNum;
cin >> cyclistInfo[i].milesRidden;
}
}
void printArray(cyclistType cyclistInfo[size])//Function to output info.
{
int i;
for(i=0; i<12; i++)
cout << cyclistInfo[i].cyclistNum <<" " <<cyclistInfo[i]. cyclistL << " ";
cout << cyclistInfo[i].milesRidden << endl;

}
void totalMiles(cyclistType cyclistInfo[size], int total)Function that adds all of the cyclist's miles ridden together and outputs a combined number.
{
int i;
for(i=0; i<12; i++)
{
total = total + cyclistInfo[i].milesRidden;
}
cout <<" The combined amount of miles ridden by all cyclists is:" << total;
cout << endl;
}
int mostMiles(cyclistType cyclistInfo[size], int max)//Function to out the rider with the most miles and his cyclist number.
{
int i;

for(i=0; i<12; i++)
if(cyclistInfo[i].milesRidden < cyclistInfo[i].milesRidden)
max = i;
cout <<" The cyclist with the must miles ridden was :" << cyclistInfo[max].milesRidden;
cout <<"and he rode for " << max << " miles. " << endl;

}
Please use code tags
http://www.cplusplus.com/articles/z13hAqkS/

I didn't check your logic, I just got rid of the compiler errors for you. You will need to make sure it does what you wan't
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
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

const int SIZE = 12;

struct cyclistType
{
	string cyclistL;
	int cyclistNum;
	int milesRidden;
};

cyclistType cyclistInfo[SIZE];
void fillArray(cyclistType cyclistInfo[]);
void printArray(cyclistType cyclistInfo[]);
void totalMiles(cyclistType cyclistInfo[], int total);
void mostMiles(cyclistType cyclistInfo[], int max);

int main()
{

	int total = 0;
	int max = 0;

	fillArray(cyclistInfo);
	printArray(cyclistInfo);
	totalMiles(cyclistInfo, total);
	mostMiles(cyclistInfo, max);

	system("pause");

	return 0;
}
void fillArray(cyclistType cyclistInfo[])//Function to fill array.
{
	int i;
	for(i=0; i<12; i++)
	{
		cout <<"Please enter the cyclist's last name, cyclist number, and how many";
		cout <<"miles they have ridden :" << endl;
		cin >> cyclistInfo[i].cyclistL >> cyclistInfo[i].cyclistNum;
		cin >> cyclistInfo[i].milesRidden;
	}
}
void printArray(cyclistType cyclistInfo[])//Function to output info.
{
	int i;
	for(i=0; i<12; i++)
		cout << cyclistInfo[i].cyclistNum <<" " <<cyclistInfo[i]. cyclistL << " ";
	cout << cyclistInfo[i].milesRidden << endl;

}
void totalMiles(cyclistType cyclistInfo[], int total)//Function that adds all of the cyclist's miles ridden together and outputs a combined number.
{
	int i;
	for(i=0; i<12; i++)
	{
		total = total + cyclistInfo[i].milesRidden;
	}
	cout <<" The combined amount of miles ridden by all cyclists is:" << total;
	cout << endl;
}
void mostMiles(cyclistType cyclistInfo[], int max)//Function to out the rider with the most miles and his cyclist number.
{
	int i;

	for(i=0; i<12; i++)
		if(cyclistInfo[i].milesRidden < cyclistInfo[i].milesRidden)
			max = i;
	cout <<" The cyclist with the must miles ridden was :" << cyclistInfo[max].milesRidden;
	cout <<"and he rode for " << max << " miles. " << endl;

} 
//end main
Thanks alot, so it was just an issue with my function calls and declarations?
Yeah and you didn't assign a value to your total variable befor using it
Topic archived. No new replies allowed.