call by reference function

I am trying to get my 'findMax' function to work, but I am not sure what to name the first part of my parameter list. I know what I have done is wrong because I keep getting the red lines under my code in the function call, but I don't know what to change it to. The comments are just part of my old code in which I could get the output needed without using the 'findMax' function. Any insight would be appreciated. Code is below:
[code]
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

struct salesTran
{
string venue;
int shirtsNum, postersNum, recordsNum;
float shirtsPrice, postersPrice, recordsPrice;
};

ostream& operator<<(ostream& os, salesTran& A)
{
os<<A.venue<<"\t"<<A.shirtsNum<<"\t"<<A.shirtsPrice<<"\t"<<A.postersNum<<"\t"<<A.postersPrice<<"\t"<<A.recordsNum<<"\t";
os<<A.recordsPrice;

return os;
}

istream& operator>>(istream& is, salesTran& A)
{
is>>A.venue>>A.shirtsNum>>A.shirtsPrice>>A.postersNum>>A.postersPrice>>A.recordsNum>>A.recordsPrice;

return is;
}

void findMax(salesTran A[], int size, int& max, int& index)
{
max= A[0].shirtsNum;
index=0;

for(int j=1; j<size; j++)
{
if (A[j].shirtsNum>max)
{
max=A[j].shirtsNum;
index=j;
}
return;
}
}


int main()
{
salesTran A[250];

ifstream fin;
fin.open("merch.txt"); //opens file that data will come from

ofstream fout;
fout.open("salesresults.txt"); //opens files where data will be sent

int z=0;
float totalSales = 0;
//float maxTotalsales = 0; // Set max total sales to zero, and assign it a value once it needs one
//int maxTotalsalesIndex=0;

int maxShirtsSold=0;
int maxShirtsIndex=0;

//int maxPostersSold=0;
//int maxPostersIndex=0;

while (fin>>A[z])
{
totalSales = A[z].shirtsNum*A[z].shirtsPrice+A[z].postersNum*A[z].postersPrice+A[z].recordsNum*A[z].recordsPrice;

findMax(salesTran A[z].shirtsNum, 250, maxShirtsSold, maxShirtsIndex);

/*if(totalSales>maxTotalsales)
{
maxTotalsales=totalSales;
maxTotalsalesIndex=z;
}
if(A[z].shirtsNum>maxShirtsSold)
{
maxShirtsSold=A[z].shirtsNum;
maxShirtsIndex=z;
}
if(A[z].postersNum>maxPostersSold)
{
maxPostersSold=A[z].postersNum;
maxPostersIndex=z;
*/ }
z++;
}

/*fout<<"The max total sales is "<<maxTotalsales<<" for "<<A[maxTotalsalesIndex].venue<<"."<<endl;
fout<<"The max shirts sold is "<<maxShirtsSold<<" in "<<A[maxShirtsIndex].venue<<"."<<endl;
fout<<"The max posters sold is "<<maxPostersSold<<" in "<<A[maxPostersIndex].venue<<"."<<endl;
fin.close();
fout.close();
*/


return 0;
}
[code]
Topic archived. No new replies allowed.