here are the error messages how do i fix it. i am creating the game called Circular Nim!
my program also keeps repeating why. anything would help!
1.error C2234: 'GamePieces' : arrays of references are illegal
2.error C2440: '=' : cannot convert from 'char' to 'char *'
3. error C2234: 'GamePieces' : arrays of references are illegal
4.error C2137: empty character constant
my program also keeps repeating why. anything would help!
1.error C2234: 'GamePieces' : arrays of references are illegal
2.error C2440: '=' : cannot convert from 'char' to 'char *'
3. error C2234: 'GamePieces' : arrays of references are illegal
4.error C2137: empty character constant
Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
void SetPrompts(int&, bool&);
void FillUpTheBoard(int&, char[]);
void PrintedBoard(char[], int&);
void ComputerTurn(char[], int&, int&);
int main()
{
int pieces, size, piecesSelection=0;
char GamePieces[20];
bool COMPUTER_TURN=false;
SetPrompts(pieces, COMPUTER_TURN);
size=pieces-1;
FillUpTheBoard(pieces, GamePieces);
PrintedBoard(GamePieces, pieces);
do
{
if(COMPUTER_TURN==true)
{
ComputerTurn(GamePieces,piecesSelection,pieces);
PrintedBoard(GamePieces,pieces);
COMPUTER_TURN=false;
}
else
{
PrintedBoard(GamePieces, pieces);
COMPUTER_TURN=true;
}
}while(GamePieces[0]!='_');
return 0;
}
void SetPrompts(int& pieces, bool& COMPUTER_TURN)
{
char userAnswer;
cout << "Welcome to the game Circular Nim!" << endl << endl;
do
{
cout << "How Many Pieces Would You Like to Start with?" << endl;
cin >> pieces;
if(pieces<5||20<pieces)
cout << "You can only choose a number between 5 and 20. Please Try Again." << endl << endl;
}while(pieces<5||20<pieces);
cout << "Would you like to go first?(Y/N)";
cin >> userAnswer;
if(userAnswer=='y'||userAnswer=='Y')
{
cout << "OK, You can Start the Game." << endl;
COMPUTER_TURN=false;
}
else
{
COMPUTER_TURN=true;
cout << "OK, I will Start the Game First." << endl;
}
}
void FillUpTheBoard(int& pieces, char& GamePieces[])
{
for(int k=0; k<pieces; k++)
{
GamePieces[k]='*';
}
}
void PrintedBoard(char& GamePieces[], int& pieces)
{
cout << endl << endl << "This is What the Current Board Looks Like" << endl << endl;
for (int k=0; k<pieces; k++)
{
cout << left << setw(3)<<k;
cout << endl;
cout << setw(2) << GamePieces[k]<<'';
cout << endl;
}
}
void ComputerTurn(char GamePieces[], int& piecesChoice, int& pieces)
{
int computerMove=piecesChoice+1;
cout << endl << endl << "OK, Now Its My Turn to Play!" << endl;
if(computerMove<=pieces&&GamePieces[computerMove]!='_')
GamePieces[computerMove]='_';
}
Comment