error C2109: subscript requires array or pointer type

I understand what the error is, but i'm not sure how to fix it. Any help would be appreciated! The *clients function is the one that it gives the error for

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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  #include <iostream>
#include <iomanip>
using namespace std;

int *numberAgents (int, int);
double *clients(int *);
void reportStuff (int, double, double *);



int main ()
{
	
	double *agents,	//dynamically allocate an array
			
			numclients,
			stuff;
	int size, *nums;
	int numAgents=0; 
	cin >> size;
	

	
	*nums=*numberAgents (numAgents, size);
	numclients=*clients(nums);
	reportStuff (numAgents, stuff, agents);


	

	//free dynamically allocated memory
	
	  //make agents point to null
	
	delete nums;






	system ("PAUSE");  //you need this for windows system
	return 0;
}




int *numberAgents (int numAgents, int size)
{
	int *agents;    //dynamically allocate an array

	//dynamically allocate an array (of memory) large enough
	agents = new int[size];

	cout << "How many insurance agents are there in the team? ";
	cin >> numAgents;

	

	return agents;
}

int *clients(int *nums)
{
	int *count;			//counter variable
	int *agents;

	

	//get the number of clients
	cout << "Enter the number of new clients each agent managed to get.\n";
	for (*count = 0; *count < nums; *count++)
	{
		cout << "Agent " << (count+1) << ": ";
		cin >> nums[*count];
		
	}
	*agents=nums[*count];

	return agents;
}

void reportStuff (int numAgents, double total, double *agents)
{
	double *average;
	
	int set[10] = {9,7,5,8,15,3,4,5,6,13};
	int *nums = set; //make nums point to set

	//display the numbers in the array
	cout << "Number of clients (data collected):";
	cout << *nums << " "<<endl; //display the first element

	while (nums < &set[9])
	{
		nums = nums + 1;
		cout << *nums << " "<<endl;
	}

	//calculate the total new clients
	for (int count = 0; count<numAgents; count++)
	{
		total = total + agents[count];
	}

	//calculate the average sales per day
	*average = total/numAgents;

	cout << fixed << showpoint << setprecision(2);
	cout << "\n\nTotal Sales: $" << total << endl;
	cout << "The averagenumber of clients: " << *average << endl;
	

}
Please, describe the type of local variable "count" in the function "clients". Then you could compare the type to the type of variable with same in function "reportStuff".

Doing so might lead to enlightment.
Topic archived. No new replies allowed.