473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Please How do I fix my program i keep getting errors!

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



Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <cmath>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. void SetPrompts(int&, bool&);
  10. void FillUpTheBoard(int&, char[]);
  11. void PrintedBoard(char[], int&);
  12. void ComputerTurn(char[], int&, int&);
  13.  
  14.  
  15. int main()
  16. {
  17.     int pieces, size, piecesSelection=0;
  18.     char GamePieces[20];
  19.     bool COMPUTER_TURN=false;
  20.  
  21.     SetPrompts(pieces, COMPUTER_TURN);
  22.     size=pieces-1;
  23.     FillUpTheBoard(pieces, GamePieces);
  24.     PrintedBoard(GamePieces, pieces);
  25.  
  26.     do
  27.     {
  28.         if(COMPUTER_TURN==true)
  29.         {
  30.             ComputerTurn(GamePieces,piecesSelection,pieces);
  31.             PrintedBoard(GamePieces,pieces);
  32.             COMPUTER_TURN=false;
  33.         }
  34.         else
  35.         {
  36.  
  37.             PrintedBoard(GamePieces, pieces);
  38.             COMPUTER_TURN=true;
  39.         }
  40.     }while(GamePieces[0]!='_');
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.     return 0;
  56. }
  57.  
  58. void SetPrompts(int& pieces, bool& COMPUTER_TURN)
  59. {
  60.  
  61.     char userAnswer;
  62.     cout << "Welcome to the game Circular Nim!" << endl << endl;
  63.  
  64.     do
  65.     {
  66.         cout << "How Many Pieces Would You Like to Start with?" << endl;
  67.         cin >> pieces;
  68.         if(pieces<5||20<pieces)
  69.             cout << "You can only choose a number between 5 and 20. Please Try Again." << endl << endl;
  70.     }while(pieces<5||20<pieces);    
  71.  
  72.      cout << "Would you like to go first?(Y/N)";
  73.      cin >> userAnswer;
  74.     if(userAnswer=='y'||userAnswer=='Y')
  75.     {
  76.         cout << "OK, You can Start the Game." << endl;
  77.         COMPUTER_TURN=false;
  78.     }
  79.     else
  80.     {
  81.         COMPUTER_TURN=true;
  82.         cout << "OK, I will Start the Game First." << endl;
  83.     }
  84.  
  85.  
  86. }
  87.  
  88. void FillUpTheBoard(int& pieces, char& GamePieces[])
  89. {
  90.     for(int k=0; k<pieces; k++)
  91.     {
  92.         GamePieces[k]='*';
  93.     }
  94. }
  95. void PrintedBoard(char& GamePieces[], int& pieces)
  96. {
  97.     cout << endl << endl << "This is What the Current Board Looks Like" << endl << endl;
  98.     for (int k=0; k<pieces; k++)
  99.     {
  100.         cout << left << setw(3)<<k;
  101.         cout << endl;
  102.  
  103.         cout << setw(2) << GamePieces[k]<<'';
  104.         cout << endl;
  105.     }
  106. }
  107. void ComputerTurn(char GamePieces[], int& piecesChoice, int& pieces)
  108. {
  109.     int computerMove=piecesChoice+1;
  110.     cout << endl << endl << "OK, Now Its My Turn to Play!" << endl;
  111.     if(computerMove<=pieces&&GamePieces[computerMove]!='_')
  112.         GamePieces[computerMove]='_';
  113. }
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
Nov 15 '08 #1
1 1578
weaknessforcats
9,208 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. void FillUpTheBoard(int& pieces, char& GamePieces[]) 
  2. etc...
  3. void PrintedBoard(char& GamePieces[], int& pieces) 
  4. etc...
  5.  
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.
Nov 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
4
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...
1
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,...
2
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...
4
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...
22
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...
4
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...
2
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...
2
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.