Arrays and Functions

I'm writing a code for my COSC class and I'm not sure how to fix this error. I haven't defined the playGame function but I don't believe that affects this error. The error given is "declaration of 'playersArray' as array of references"

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
#include <iostream>
#include <cstdlib>
using namespace std;

const int MAX_SQUARES = 225;
const int MAX_PLAYERS = 12;

int initializePlayers(int playersArray[]);
int initializeBoard(int gameboardArray[]);
void printGameInfo(int playersArray[], int numberOfPlayers, int sizeOfBoard);

void playGame(int& playersArray[], int& numberOfPlayers, int& gameboardArray[], int& sizeOfBoard, int& maxSpin);

int main() {
  int gameboard[MAX_SQUARES+1];
  int players[MAX_PLAYERS];
  int boardSize;
  int maxSpin;
  int numPlayers;
  int seed;

  cin >> seed;
  srand(seed);

  cin >> maxSpin;

  numPlayers = initializePlayers(players);

  boardSize = initializeBoard(gameboard);

  playGame(players, numPlayers, gameboard, boardSize, maxSpin);

  printGameInfo(players, numPlayers, boardSize);

  return 0;
}


void printGameInfo(int playersArray[], int numberOfPlayers, int sizeOfBoard) {
  int i;
  for (i = 0; i < numberOfPlayers; i++) {
    cout << "player " << i << ": " << playersArray[i] << endl;
  }
  for (i = 0; i < numberOfPlayers; i++) {
    if (playersArray[i] == sizeOfBoard) 
      cout << "player " << i << " is a winner!\n";
  }
}

int initializePlayers(int playersArray[]) {
  int numberOfPlayers;
  int i;


  cin >> numberOfPlayers;

  for (i = 0; i < numberOfPlayers; i++) {
    playersArray[i] = 0;
  }

  return numberOfPlayers;
}


int initializeBoard(int gameboardArray[]) {
  int i;
  int squareNum, destinationNum;
  int sizeOfBoard;

  cin >> sizeOfBoard;

  for (i = 0; i < sizeOfBoard+1; i++) {
    gameboardArray[i] = i;
  }
  while (cin >> squareNum >> destinationNum) {
 
    gameboardArray[squareNum] = destinationNum;
  }
  return sizeOfBoard;
}

void playGame(int& playersArray[], int& numberOfPlayers, int& gameboardArray[], int& sizeOfBoard, int& maxSpin){
	
}


Thank you in advance
Last edited on
void playGame(int& playersArray[], int& numberOfPlayers, int& gameboardArray[], int& sizeOfBoard, int& maxSpin);

void playGame(int playersArray[], int& numberOfPlayers, int gameboardArray[], int& sizeOfBoard, int& maxSpin);
Topic archived. No new replies allowed.