ok so i am almost done with this assignment but i keep getting an error on line 51 about my function i am calling. please help me!

//calculate energy bill part 9ish
// 
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int i;
void sort(int[], int[], string[], int);
void c(int[], int[], int);
int customer[25];
int usagekwh[25];
double cost[25];
int arraysize;
string name[25];
int search(int[],int, int);
int main()
{
	cout<<"enter the number of customers being processed ";
	cin>>arraysize;

	ifstream input("K:/C++/energy bill part 3/input.txt", ios::in);
	if (!input){
		cerr << "File could not be opened\n";
		exit(1);
	}
	for (i=0; i<arraysize; i++)
	{
		//cout<<"i has top value:"<<i<<endl;
		input>>customer[i];
		//cout<<account[i]<<endl;
		//read the name
		input.ignore(1);
		getline(input,name[i]);
		
		input>>usagekwh[i];
		
	}

	sort(usagekwh, customer, name, arraysize);
	c(usagekwh, customer, arraysize);
	
	int x, searchv;
	char search;

	for(search='Y'; search='Y';)
	{
		cout<<"Enter the customer number that you wish to search for ";
		cin>>searchv;

		x=search(usagekwh, searchv, arraysize);

		if (x=searchv)
		{
			cout<<"Customer was found"<<endl;
			cout<<usagekwh[x]<<"   "<<name[x]<<"   "<<customer[x]<<"   "<<cost[x]<<endl;

		}
		else
		{
			cout<<"Could not find customer"<<endl;
		}
		cout<<"Would you like to search for another customer (Y or N)";
		cin>>search;
	}
}


void c(int usagekwh[], int customer[], int arraysize)

{
double rate, t;

double total_usage, total_cost, average_cost, average_usage;

	total_cost=0;
	total_usage=0;
	average_cost=0;
	average_usage=0;
	
cout<<setw(20)<<left<<"Customer Number"<<setw(25)<<"Customer Name"<<setw(10)<<"KWH Used"<<setw(10)<<"Amount Due"<<endl;

	
	//ditirmen what rate to be used

for (i=0; i<arraysize; i++)
{
	if (usagekwh[i]<=300)
	{
		rate=0.10;
		t=rate*usagekwh[i];
	}
	else if (usagekwh[i]<800)
	{
		rate=0.09;
		t=30+rate*(usagekwh[i]-300);
	}
	else if (usagekwh[i]<1300)
	{
		rate=0.07;
		t=30+(500*.09)+(rate*(usagekwh[i]-800));
	}
	else
	{
		rate=0.055;
		t=30+(500*.09)+(500*.07)+(rate*(usagekwh[i]-1300));
	}
	cost[i]=t;
	//output

	cout<<setw(12)<<right<<customer[i]<<setw(8)<<"       "<<setw(25)<<left<<name[i]<<setw(7)<<right<<usagekwh[i]<<setw(3)<<"   "<<setw(8)<<fixed<<showpoint<<setprecision(2)<<cost[i]<<endl;

}

//compute the totals

for (i=0; i<7; i++)
{
	total_usage=total_usage+usagekwh[i];
	total_cost=total_cost+cost[i];
	
}

average_usage=total_usage/7;
average_cost=total_cost/7;

//output

cout<<"______________________________________________"<<endl;
cout<<"                                 "<<endl;
cout<<setw(9)<<"         "<<setw(10)<<right<<"Usage(kwh)"<<setw(26)<<right<<"Amount Due(dollars)"<<endl;
cout<<"______________________________________________"<<endl;
cout<<setw(9)<<right<<"Total"<<setw(10)<<setprecision(2)<<showpoint<<fixed<<total_usage<<setw(26)<<total_cost<<endl;
cout<<setw(9)<<right<<"Average"<<setw(10)<<setprecision(2)<<showpoint<<fixed<<average_usage<<setw(26)<<average_cost<<endl;
}


void sort(int usagekwh[], int customer[], string name[], int arraysize)
{
	int holdu, holdc, p, i;
	string holdn;

	//nested for loops to cycle thru array
	for(p=0; p<arraysize; p++)
	{
		for(i=0; i<(arraysize-1); i++)
		{
			//if statements
			if(customer[i]>customer[i+1])
			{
				//switch usage
				holdu=usagekwh[i];
				usagekwh[i]=usagekwh[i+1];
				usagekwh[i+1]=holdu;

				//switch customer number
				holdc=customer[i];
				customer[i]=customer[i+1];
				customer[i+1]=holdc;

				//switch names
				holdn=name[i];
				name[i]=name[i+1];
				name[i+1]=holdn;

			}
		}
	}
	return;
}
int search(int useagekwh[], int searchv, int arraysize)
{

	cout<<endl;
		
		int low, high;
		low=0;
		high=arraysize-1;

		int middle;
		while (low <= high)
		{
			middle=(low+high)/2;
			if(searchv==usagekwh[middle])
				return middle;
			else if (searchv < usagekwh[middle])
				high = middle-1;
			else
				low = middle +1;
		}

		return -1;
}

thank you for any help

You're presumably trying to call your function called search() but you also have a local variable called search too. The compiler doesn't understand, and thinks you're referring to that variable. I'd suggest you call your variable something else instead

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.