Need help with a Function

Can someone please tell me what is wrong with my function?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  //Protoype
   void registration(HANDLE hdl, int x, int y, char str[], char errMessage[]);
  
//function
void registration(HANDLE hdl, int x, int y, char str[], char errMessage)
{
	char reg, countAlpha, countDigit;
	
		gotoXY(hdl, x, y); cin>>reg; reg=tolower(reg);
		if(isdigit(str[x])!=0)
			countDigit++;
		else if (isalpha(str[x])!=0)
			countAlpha++;
		cin.ignore(10, '\n');
	_getche();
}
//This is the error message i am getting below
cars[size].regNo=registration(hdl,32, 17,

I am trying to add a car registration but my function keeps bringing up errors :(
Could you post your errors as given by the compiler? That would make it easier for us to work out what is going wrong. Also tell us what you want the function to actually do

I can see a few things:
First, your prototype is different to the function definitions, in that errMessage[] is different to errMessage[\tt] (one is an array of chars, the other is a single char).

You are not initializing [tt]countDigit
or countAlpha, so when you increment them you will still only get junk. You probably meant this:
1
2
static char countAlpha = 0;
static char countDigit = 0;


You are trying to set the value regNo to your the return function of your registration function, but it returns void, so this should give an error too.

Finally, (I assume this was accidental), the parameters passed registration upon its use are incomplete.
Im trying to display Car details by the regNo Here is the code. And how should i fix the function definition from the prototype?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void add (HANDLE hdl, struct carStock cars[ ], int & size)//add carStock details
{
	
	int no;
	char filename[]="Carinputscreen.txt";
	
	getscreen(hdl,filename );
	cars[size].carStockNo=cars[size-1].carStockNo+1;
	gotoXY(hdl,32,7); cout<<cars[size].carStockNo;
	validateString(hdl, 32,9,2,25,cars[size].model,"description must be between 2 and 25 characters");
	cars[size].make=validateChar(hdl, 32,11,"Please enter either A,F,M,V for the make");
	cars[size].costPrice=validateDouble(hdl,32,19,250,20000,"Please enter between 250 and 20000");
	cars[size].sellingPrice=validateDouble(hdl,32,21,450,27000,"Please enter between 450 and 27000");

   size++; 
	_getche();
}

heres the code to display the car details by the stock
1
2
3
4
5
6
7
8
9
10
void displayCat (HANDLE hdl, struct carStock cars[ ], int size)// display carStock details by regNo
{
	int x;
	int page=0;
	char cat[2];
	system("cls");
	
	//complete code
	press_key(hdl, 1,26);
}
Topic archived. No new replies allowed.