I keep getting errors and i looked relooked I cant seem to see what wrong.
from my code can see u where the errors are coming from.
here are the error messages:
1.warning C4101: 'size' : unreferenced local variable
2. warning C4553: '==' : operator has no effect; did you intend '='?
3. warning C4101: 'userAnswer' : unreferenced local variable
4.error LNK2019: unresolved external symbol "void __cdecl FillUpTheBoard( int,char * const)" (?FillUpTheBoar d@@YAXHQAD@Z) referenced in function _main
5. error LNK2019: unresolved external symbol "int __cdecl isillegal(char * const,int,int,i nt)" (?isillegal@@YA HQADHHH@Z) referenced in function "void __cdecl UserPlayerTurn( char * const,int &,int)" (?UserPlayerTur n@@YAXQADAAHH@Z )
6: fatal error LNK1120: 2 unresolved externals -
-
#include <iostream>
-
#include <string>
-
#include <iomanip>
-
#include <cmath>
-
-
-
using namespace std;
-
-
void SetPrompts(int&, bool&);
-
void FillUpTheBoard(int, char[]);
-
void PrintedBoard(char[], int);
-
void ComputerPlayerTurn(char[], int&, int);
-
void UserPlayerTurn(char[], int&, int);
-
int isillegal(char[], int, int, int);
-
void TheMove(char [], int, int, int);
-
int theLastTurn(char [], int);
-
-
-
-
int main()
-
{
-
int pieces, size, piecesSelection=0, score_OfUser=0, score_ComputerPlayer=0;
-
char GamePieces[20];
-
bool COMPUTER_TURN, COMPUTER_FIRST, toPlayAgain;
-
do
-
{
-
-
-
SetPrompts(pieces, COMPUTER_FIRST);
-
COMPUTER_TURN=COMPUTER_FIRST;
-
FillUpTheBoard(pieces, GamePieces);
-
//PrintedBoard(GamePieces, pieces);
-
-
-
-
do
-
{
-
if(COMPUTER_TURN==true)
-
{
-
ComputerPlayerTurn(GamePieces,piecesSelection,pieces);
-
PrintedBoard(GamePieces,pieces);
-
COMPUTER_TURN=false;
-
}
-
else
-
{
-
UserPlayerTurn(GamePieces,piecesSelection, pieces);
-
PrintedBoard(GamePieces, pieces);
-
COMPUTER_TURN=true;
-
}
-
}while(!theLastTurn(GamePieces, pieces));
-
if(COMPUTER_TURN)
-
{
-
score_OfUser++;
-
cout<< "Congratulations, You Won The Game Hoorray for You!" << endl;
-
}
-
else
-
{
-
score_ComputerPlayer++;
-
cout <<"Opps!, you made the last turn sorry you lost the Game!" <<endl;
-
}
-
cout << "The Score now is:" << score_OfUser << ":Computer Player" << score_ComputerPlayer<<endl;
-
cout << "Would Like to Play again?" << endl;
-
char userAnswer;
-
cin >> userAnswer;
-
if(userAnswer=='y'||userAnswer=='Y')
-
{
-
cout << "Lets Start Over!" << endl;
-
toPlayAgain=true;
-
}
-
else
-
{
-
toPlayAgain=false;
-
cout << "Thank You for Playing Circular Nim. Please come again!" << endl;
-
}
-
}while(toPlayAgain==true);
-
-
-
-
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;
-
}
-
for(int k=0; k<pieces; k++)
-
{
-
-
cout << setw(2)<< GamePieces[k]<< ' ';
-
cout << endl;
-
}
-
}
-
void ComputerPlayerTurn(char GamePieces[], int& piecesChoice, int pieces)
-
{
-
cout << endl << endl << "Ok Now its My Turn!"<<endl;
-
for(int k=0; k<pieces; k++)
-
{
-
if(GamePieces[k]=='*')
-
{
-
GamePieces[k]=='*';
-
break;
-
}
-
}
-
-
}
-
void UserPlayerTurn(char GamePieces[], int& piecesSelection, int size)
-
{
-
char userAnswer;
-
int count;
-
int illegal;
-
-
do
-
{
-
cout << "Now Its Your turn! How Many Pieces would you like?";
-
cin>> count;
-
while(count>3)
-
{
-
cout <<"This amount of pieces is illegal.\n";
-
cout << "Please enter a different integer \n";
-
cin >> count;
-
}
-
cout << "Enter the first piece to take \n";
-
cin >> piecesSelection;
-
illegal=isillegal(GamePieces,size, count, piecesSelection);
-
if(illegal)
-
{
-
cout<<"This is an illegal move \n";
-
cout<< "Start Over! \n";
-
}
-
}while(illegal);
-
TheMove(GamePieces, size, count, piecesSelection);
-
-
}
-
int isIlegal(char GamePieces[], int size, int count, int firstPiece)
-
{
-
int illegal=0;
-
if(firstPiece>0)
-
{
-
for(int k=0; k<count; k++)
-
{
-
int checkPiece=(k+firstPiece)%size;
-
if(checkPiece==0) checkPiece=size;
-
if(GamePieces[checkPiece-1]=='_')
-
{
-
illegal=1;
-
break;
-
}
-
}
-
}
-
else
-
{
-
illegal=1;
-
}
-
return illegal;
-
}
-
void TheMove(char GamePieces[], int size, int count, int firstPiece)
-
{
-
for(int k=0; k<count; k++)
-
{
-
int thePieceToChoose=(k+firstPiece)%size;
-
if(thePieceToChoose==0)thePieceToChoose=size;
-
GamePieces[thePieceToChoose-1]='_';
-
}
-
-
-
}
-
int theLastTurn(char GamePieces[], int pieces)
-
{
-
int last=1;
-
for(int k=0; k<pieces; k++)
-
{
-
if(GamePieces[k]=='*')
-
{
-
last=0;
-
break;
-
}
-
}
-
return last;
-
}
-
-
3 2227
All they except linking errors are warning, i do not know what exactly is wrong because i don't want to search all the text for possible occasion of them ( as you didn't provide line numbers for them). They are written in plain English and are easy to fix if you know line numbers. Link error comes from the fact you declared
void FillUpTheBoard( int pieces, char GamePieces[])
and implemented
void FillUpTheBoard( int& pieces, char GamePieces[])
with & .
You can't just 4ange valued-passed to reference-passed argument.
Change int to one without & if you are not changing pieces and not passing changed value back to main program.
You have two errors:
1) The function prototype for FillUpThe Board is incorrect. You have: -
void FillUpTheBoard(int, char[]);
-
when it should be: -
void FillUpTheBoard(int&, char[]);
-
2) The isillegal function name is misspelled. You have:
when it should be: donbock 2,426
Recognized Expert Top Contributor
The following snippet is from lines 140-144. - if(GamePieces[k]=='*')
-
{
-
GamePieces[k]=='*';
-
break;
-
}
The line before the break compares GamePieces[k] to '*'. If they are equal, then the integer value '1' is discarded; otherwise the integer value '0' is discarded. The compiler warning points out that '==' in this context is meaningless; and goes on to suggest that perhaps you meant '='. In actuality, this line should probably be deleted.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Yan |
last post by:
Hi. I am having trouble running my aspx code. I created two simple
webforms, which i try to run from two different directories one is
giving me
Compiler Error Message: The compiler failed with error code 128.
and another one which is in a different directory is giving me
Server Application Unavailable
I am using ASP.NET 1.1.4322.0, i searched around on google and deja,
|
by: Kim Nørby Andersen |
last post by:
Hello there
I am lost. i receive the output in the bottom, from a site that runs
excellently on our development server, but dies on the customer. We have had
a first version running at the customer, did some changes, recompiled,
zipped and sent it back to them, but then it screwed up.
As a part of the debugging process, the ASP.NET has been set to run as
SYSTEM, and all folders described in...
|
by: Robert |
last post by:
Every time I navigate to any .aspx file on my computer, I get the error below. According to MSDN this indicates that my CLR is corrupt, but I've re-installed the .NET framework with no help. Also reinstalled VS.NET; still nothing. Any ideas?
Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code...
|
by: JTrigger |
last post by:
When I compile my project using the IDE on a development machine it works
just fine. When I compile it on the server using csc.exe, I get the
following error when I try to bring it up in the web browser. What is the
issue?
Thanks,
Jim
Server Error in '/psnRequest' Application.
----------------------------------------------------------------------------
|
by: james margey |
last post by:
Hi to all,
I have spent 3 days at this error and i have two days to go for a
deadline, and i am about to go off my nut, the reason being: Microsoft
dont seem to be able to provide a solution, I have trawled the web and
the few that have the same error have not being provided a fix. This
error occurs if i make the slightest change in my project. If i
REBUILD my project no error occurs. So i keep having to rebuild my
project - this is not...
| |
by: Bruce |
last post by:
We suddenly got a mysterious error message on our Windows Server 2003 (SP1)
after rolling out a bug fix on a web services application this morning. The
application compiles and runs fine on the development workstation (from vs
2005 on Windows XP Pro), but when I run "Copy Web Site..." to move the app
out from VS to the server, then all accesses to the web service via a
browser show this error message: "Compiler Error Message: CS0006:...
|
by: Joshua Moore |
last post by:
/* Hi, I was hoping someone could help me with this problem. I did my
work and worked my way through the usual compiler messages, but I have
run against some problem I can't identify. The compiler error message
is unintelligable -- to me anyway. Anyway: Here is the code, maybe
someone can tell me what is wrong with it. */
//buysome.cpp
//Joshua Moore
//the part responsible for the buying part of the farm pos simulation
program
|
by: David Mathog |
last post by:
Do any of you happen to have links to compendiums (or heaven forbid, an
actual manual) which maps compiler warnings and errors to examples of
actual code problems? In this case I'm specifically looking for one
for gcc. The general problem is of course that the compiler messages
must be short, and that tends to make them so cryptic that it isn't
always immediately obvious what the problem is. It almost makes me long
for the days when the...
|
by: zaklost |
last post by:
Hello All,
I'm really new to this, so sorry ahead of time. Trying to get data to be posted into a table along with other information that's already being put into there.
I'm using access 2003.
After hitting to post I get the error message : Run-time error '3346'
Here is the code:
|
by: =?GB2312?B?yum09MXt?= |
last post by:
today I forgot to include some header,then I found the error message by the compiler is quite strange.
so I want to know exactly the inner details of the compiler impletation,if possible.
and I want to know what does the standard say about this situation.
here is the code just to demonstrate the error.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |