Calling functions!

I need help with calling functions in my code.

1
2
cout<<"Correct Digits: "<< int correctdigits(int a, int g, int size);
cout<<"Correct Spots: "<< int correctspots(int a, int g, int size);


Above is in int main, I am trying to call for these functions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int correctdigits(int a[],int g[], int size){
	int count = 0;
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 4; j++){
			if(a[i] == g[j]){
				count++;
		 	}
		}
	}
	return count;
}

//spot function
int correctspots(int a[], int g[], int size){
	int countx = 0;
		for(int i = 0; i < size; i++){
			if(a[i] == g[i]){
				countx++;
			}
		}
		return countx;
}

but I get this error: expected primary expression before 'int'
Last edited on
Hello YeetParadox,

but I get this error: expected primary expression before 'int'
Which "int"??

looks like it is the "int" in the "cout" statement that should not be there. All you need when calling a function like this the return value is not needed. Just the function's name.

Next time post the complete error message. And because the line numbers do not always match point out which line it refers to.

Hope that helps,

Andy
Just to put it another way:

When calling functions, don't put the type with the arguments :+)
closed account (E0p9LyTq)
std::cout << "Correct Digits: "<< correctdigits(a, g, size);
Topic archived. No new replies allowed.