473,606 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASAP!! My compiler is giving me error message.

36 New Member
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


Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <iomanip>
  5. #include <cmath>
  6.  
  7.  
  8. using namespace std;
  9.  
  10. void SetPrompts(int&, bool&);
  11. void FillUpTheBoard(int, char[]);
  12. void PrintedBoard(char[], int);
  13. void ComputerPlayerTurn(char[], int&, int);
  14. void UserPlayerTurn(char[], int&, int);
  15. int isillegal(char[], int, int, int);
  16. void TheMove(char [], int, int, int);
  17. int theLastTurn(char [], int);
  18.  
  19.  
  20.  
  21. int main()
  22. {
  23.     int pieces, size, piecesSelection=0, score_OfUser=0, score_ComputerPlayer=0;
  24.     char GamePieces[20];
  25.     bool COMPUTER_TURN, COMPUTER_FIRST, toPlayAgain;
  26.     do
  27.     {
  28.  
  29.  
  30.         SetPrompts(pieces, COMPUTER_FIRST);
  31.         COMPUTER_TURN=COMPUTER_FIRST;
  32.         FillUpTheBoard(pieces, GamePieces);
  33.         //PrintedBoard(GamePieces, pieces);
  34.  
  35.  
  36.  
  37.         do
  38.         {
  39.             if(COMPUTER_TURN==true)
  40.             {
  41.                 ComputerPlayerTurn(GamePieces,piecesSelection,pieces);
  42.                 PrintedBoard(GamePieces,pieces);
  43.                 COMPUTER_TURN=false;
  44.             }
  45.             else
  46.             {
  47.                 UserPlayerTurn(GamePieces,piecesSelection, pieces);
  48.                 PrintedBoard(GamePieces, pieces);
  49.                 COMPUTER_TURN=true;
  50.             }
  51.         }while(!theLastTurn(GamePieces, pieces));
  52.         if(COMPUTER_TURN)
  53.         {
  54.             score_OfUser++;
  55.             cout<< "Congratulations, You Won The Game Hoorray for You!" << endl;
  56.         }
  57.         else
  58.         {
  59.             score_ComputerPlayer++;
  60.             cout <<"Opps!, you made the last turn sorry you lost the Game!" <<endl;
  61.         }
  62.         cout << "The Score now is:" << score_OfUser << ":Computer Player" << score_ComputerPlayer<<endl;
  63.         cout << "Would Like to Play again?" << endl;
  64.         char userAnswer;
  65.         cin >> userAnswer;
  66.         if(userAnswer=='y'||userAnswer=='Y')
  67.         {
  68.             cout << "Lets Start Over!" << endl;
  69.             toPlayAgain=true;
  70.         }
  71.         else
  72.         {
  73.             toPlayAgain=false;
  74.             cout << "Thank You for Playing Circular Nim. Please come again!" << endl;
  75.         }
  76.     }while(toPlayAgain==true);
  77.  
  78.  
  79.  
  80.     return 0;
  81. }
  82.  
  83. void SetPrompts(int& pieces, bool& COMPUTER_TURN)
  84. {
  85.  
  86.     char userAnswer;
  87.     cout << "Welcome to the game Circular Nim!" << endl << endl;
  88.  
  89.     do
  90.     {
  91.         cout << "How Many Pieces Would You Like to Start with?" << endl;
  92.         cin >> pieces;
  93.         if(pieces<5||20<pieces)
  94.             cout << "You can only choose a number between 5 and 20. Please Try Again." << endl << endl;
  95.     }while(pieces<5||20<pieces);    
  96.  
  97.      cout << "Would you like to go first?(Y/N)";
  98.      cin >> userAnswer;
  99.     if(userAnswer=='y'||userAnswer=='Y')
  100.     {
  101.         cout << "OK, You can Start the Game." << endl;
  102.         COMPUTER_TURN=false;
  103.     }
  104.     else
  105.     {
  106.         COMPUTER_TURN=true;
  107.         cout << "OK, I will Start the Game First." << endl;
  108.     }
  109.  
  110.  
  111. }
  112.  
  113. void FillUpTheBoard(int& pieces, char GamePieces[])
  114. {
  115.     for(int k=0; k<pieces; k++)
  116.     {
  117.         GamePieces[k]='*';
  118.     }
  119. }
  120. void PrintedBoard(char GamePieces[], int pieces)
  121. {
  122.     cout << endl << endl << "This is What the Current Board Looks Like" << endl << endl;
  123.     for (int k=0; k<pieces; k++)
  124.     {
  125.         cout << left << setw(3)<<k;
  126.         cout << endl;
  127.     }
  128.     for(int k=0; k<pieces; k++)
  129.     {
  130.  
  131.         cout << setw(2)<< GamePieces[k]<< ' ';
  132.         cout << endl;
  133.     }
  134. }
  135. void ComputerPlayerTurn(char GamePieces[], int& piecesChoice, int pieces)
  136. {
  137.     cout << endl << endl << "Ok Now its My Turn!"<<endl;
  138.     for(int k=0; k<pieces; k++)
  139.     {
  140.         if(GamePieces[k]=='*')
  141.         {
  142.             GamePieces[k]=='*';
  143.             break;
  144.         }
  145.     }
  146.  
  147. }
  148. void UserPlayerTurn(char GamePieces[], int& piecesSelection, int size)
  149. {
  150.     char userAnswer;
  151.     int count;
  152.     int illegal;
  153.  
  154.     do
  155.     {
  156.         cout << "Now Its Your turn! How Many Pieces would you like?";
  157.         cin>> count;
  158.         while(count>3)
  159.         {
  160.             cout <<"This amount of pieces is illegal.\n";
  161.             cout << "Please enter a different integer \n";
  162.             cin >> count;
  163.         }
  164.         cout << "Enter the first piece to take \n";
  165.         cin >> piecesSelection;
  166.         illegal=isillegal(GamePieces,size, count, piecesSelection);
  167.         if(illegal)
  168.         {
  169.             cout<<"This is an illegal move \n";
  170.             cout<< "Start Over! \n";
  171.         }
  172.     }while(illegal);
  173.         TheMove(GamePieces, size, count, piecesSelection);
  174.  
  175. }
  176. int isIlegal(char GamePieces[], int size, int count, int firstPiece)
  177. {
  178.     int illegal=0;
  179.     if(firstPiece>0)
  180.     {
  181.         for(int k=0; k<count; k++)
  182.         {
  183.             int checkPiece=(k+firstPiece)%size;
  184.             if(checkPiece==0) checkPiece=size;
  185.             if(GamePieces[checkPiece-1]=='_')
  186.             {
  187.                 illegal=1;
  188.                 break;
  189.             }
  190.         }
  191.     }
  192.     else
  193.     {
  194.         illegal=1;
  195.     }
  196.     return illegal;
  197. }
  198. void TheMove(char GamePieces[], int size, int count, int firstPiece)
  199. {
  200.     for(int k=0; k<count; k++)
  201.     {
  202.         int thePieceToChoose=(k+firstPiece)%size;
  203.         if(thePieceToChoose==0)thePieceToChoose=size;
  204.         GamePieces[thePieceToChoose-1]='_';
  205.     }
  206.  
  207.  
  208. }
  209. int theLastTurn(char GamePieces[], int pieces)
  210. {
  211.     int last=1;
  212.     for(int k=0; k<pieces; k++)
  213.     {
  214.         if(GamePieces[k]=='*')
  215.         {
  216.             last=0;
  217.             break;
  218.         }
  219.     }
  220.     return last;
  221. }
  222.  
  223.  
Nov 17 '08 #1
3 2227
newb16
687 Contributor
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.
Nov 18 '08 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
You have two errors:
1) The function prototype for FillUpThe Board is incorrect. You have:
Expand|Select|Wrap|Line Numbers
  1. void FillUpTheBoard(int, char[]); 
  2.  
when it should be:
Expand|Select|Wrap|Line Numbers
  1. void FillUpTheBoard(int&, char[]); 
  2.  
2) The isillegal function name is misspelled. You have:
Expand|Select|Wrap|Line Numbers
  1. isIlegal
  2.  
when it should be:
Expand|Select|Wrap|Line Numbers
  1. isillegal
  2.  
Nov 18 '08 #3
donbock
2,426 Recognized Expert Top Contributor
The following snippet is from lines 140-144.
Expand|Select|Wrap|Line Numbers
  1.         if(GamePieces[k]=='*') 
  2.         { 
  3.             GamePieces[k]=='*'; 
  4.             break; 
  5.         } 
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.
Nov 18 '08 #4

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

Similar topics

0
3783
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,
5
2093
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...
3
5110
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...
9
2287
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. ----------------------------------------------------------------------------
4
5406
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...
1
4132
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:...
8
1855
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
6
2259
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...
4
1739
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:
8
2442
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.
0
7981
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,...
1
8127
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,...
0
8320
tracyyun
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...
0
6803
agi2029
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...
1
5994
isladogs
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...
0
5470
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();...
0
3952
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...
0
4011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2458
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

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.