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 -
#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]='_';
-
}
-
-
-
-
-
-
-
1 1578 -
void FillUpTheBoard(int& pieces, char& GamePieces[])
-
etc...
-
void PrintedBoard(char& GamePieces[], int& pieces)
-
etc...
-
You cannot have an array of references. This argument should be an array of char.
Remember, when you pass an array ot a function all you pass is the address of element 0. In this case the address of a char.
Fix these errors and most of the opthers will go away.
The one about an empty character literal means that when you use ' ' for a character literal, you need to put a character in there.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike |
last post by:
I am sure that I am making a simple boneheaded mistake and I would
appreciate your help in spotting in. I have just installed
apache_2.0.53-win32-x86-no_ssl.exe
php-5.0.3-Win32.zip...
|
by: MJ |
last post by:
I am using the following script to connect but keep getting
<?php
$conn = mysql_connect("", "mjohn", "");
mysql_select_db("testDB",$conn);
?>
but keep getting this error
Fatal error: Call to...
|
by: steve smith |
last post by:
Hi I have just downloaded the Borland C# Builder and the Micorsoft
..Net framework SDK v1.1 from the borland webist, and i am trying to
get a simple program to run, however I keep getting errors,...
|
by: Erik |
last post by:
Hi Everyone,
I'm having real problems compiling some source for eVC4++. The errors
I am getting are below:
It all seems to be centred around winsock. If I move the afsock.h
reference to before...
|
by: vagrantbrad |
last post by:
I'm using python 2.4 running on Fedora Core 4. I have written a python
program called ipscan.py that checks the external ip address of my
cable internet connection, and on change, will update the...
|
by: KitKat |
last post by:
I need to get this to go to each folders: Cam 1, Cam 2, Cam 4, Cam 6, Cam 7,
and Cam 8. Well it does that but it also needs to change the file name to
the same folder where the file is being...
|
by: gordon |
last post by:
Hi
I am still fairly new to C#.net and I sometimes make basic program design
mistakes - particularyly in the context of paying attention to OOP
principles.
At the moment I am working on an...
|
by: d0ugg |
last post by:
Hi,
I'm doing a FRACTION program for one of my Programming classes and I'm getting some errors that I can't figure it out.
Here is the Assignment:
1. Convert the fraction structure into a...
|
by: Manikandan |
last post by:
Hi,
I have a program written in .Net Framework 1.1 using Visual studio
enterprise edition 2003.
I tried compiling the same program in visual c# express edition 2005.
I'm getting following...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |