term does not evaluate to a function taking X arguments

Can someone help me figure out what I'm doing wrong that's causing this error on lines 34 & 35 (function lines 70-80)? I'm only just beginning to understand about 10% of what I'm doing (counting comments) and I just can't understand what's causing the error. Thanks for any direction you can give!!

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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Lottery compares user input to randomly generated numbers to see if they match.

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>            
#include <ctime>              

using namespace std;
     
     //function prototypes
void getUserData(int [], int);         
void populateLotteryArray(int[], int); 
int compare(int[], int[], int);   
void showValues(int[], int);

int _tmain(int argc, _TCHAR* argv[])
{
	const int SIZE = 5;
	int lottery[SIZE];   //array that holds the random numbers
	int user[SIZE];      //array that holds the user input
	int compare;
	int a;
	int b;
	int len;
	
	populateLotteryArray(lottery, SIZE);     //calls the function that generates random numbers
	cout << "\nThe generated numbers: \n";   //this prints out the randomly generated numbers.
	showValues(lottery, SIZE);

	getUserData(user, SIZE);               
	cout << "\nThe numbers you entered are: \n";   //this prints out numbers entered by the user.
	showValues(user, SIZE);

	compare(a, b, len); 
	int matches = compare(a, b, len);

	showValues(a, SIZE);
	
	/*If the numbers the user enters match the randomly generated number, print out message stating 'You are a winner'. 
	  Otherwise, print out message that you are not a winner.
	*/

	return 0;
}


/*      FUNCTIONS      */

void populateLotteryArray(int lot[], int SIZE)    // This function generates 5 random numbers from 0-9. 
{
	int count;
	int seed = time(0);                           // Get the system time.
	srand(seed);       

	for (count = 0; count < SIZE; count++)
	{
		lot[count] = rand() % 10;
	} 
}

void getUserData(int user[], int SIZE)           // This function gets 5 numbers from 0-9 and puts it in the lottery array. 
{
	int count;
	cout << "Enter 5 numbers from 0-9 (separated by a space) \n";
	cout << "and then press the enter key. \n \n";
	for (count = 0; count < SIZE; count++)
		cin >> user[count];
}

int compare(int a[], int b[], int len)           // This function compares the input with the random numbers to see if they match.  
{
	int matches = 0;
	int count;
	for (count = 0; count < len; count++)
	{
		if (a[count] == b[count] )
		  matches++;
	}
	return matches;
}

void showValues(int a[], int SIZE)
{
	int count;
	for (count = 0; count < SIZE; count++)
	{   
		cout << " " << a[count];               
	}
	cout << endl;
}
Ah, the lottery program :).

compare() is expecting arrays, but you give it integers (a and b). And actually, it looks like you aren't initializing a and b. compare() should be given user and lottery anyway (I would guess).

As a side, some things about the lottery. Lottery numbers do not repeat, so your populateLotteryArray() should deal with that. Perhaps some validation for the user too. Also, it doesn't matter what order the users picks are. Your compare() compares a[i] to b[i], while it should be comparing a[i] to every value in b.

At least, thats how we're doing it in Java :)
Thank you!!
Topic archived. No new replies allowed.