I'm getting a fatal error: fatal error LNK1120: 2 unresolved externals.
Also I know that my code won't work as it should as well, nut I want to figure out the issues in it, but I can't because of these errors.. I'm new, so I'm sorry for any of my ignorance in advance.
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
void PrintHeader(void);
void PrintTurnSeparator(void);
int RollDice();
int Move(int, int);
void PrintOneMove(string, int, int, int, int);
bool Win(int, int);
int CheckChutes(int);
int CheckLadders(int);
void GetPlayerNames(string &, int);
int Move(int position, int distance)
{
int retval;
retval = position + distance;
retval = CheckChutes(retval);
retval = CheckLadders(retval);
return retval;
}
void PrintOneMove(string name, int turn, int position, int die, int newPosition)
{
cout << name << "\t\t" << turn << "\t\t" << position << "\t\t" << die << "\t\t" << newPosition << endl;
}
bool Win(int p1, int p2)
{
if (p1 >= 81 || p2 >= 81)
return true;
else
return false;
}
int CheckChutes(int position)
{
if (position == 11)
return position = 4;
else if (position == 15)
return position = 7;
else if (position == 30)
return position = 21;
else if (position == 44)
return position = 31;
else if (position == 58)
return position = 43;
else if (position == 64)
return position = 54;
}
int CheckLadders(int position)
{
if (position == 8)
return position = 16;
else if (position == 12)
return position = 27;
else if (position == 28)
return position = 39;
else if (position == 33)
return position = 46;
else if (position == 48)
return position = 55;
else if (position == 59)
return position = 75;
}
void GetPlayerNames(string &name, int num)
{
cout << "Player " << num << " please input your name: ";
cin >> name;
int i = 0;
// Validate the name.
while (!(isalpha(name[i])) && (name[i] != '.') && (!isspace(name[i])))
{
cout << "Please enter a vaid name!" << endl;
cout << "Player " << num << " please input your name: ";
cin >> name;
i = 0;
"Unresolved external" usually means that you are trying to call a function that you never gave a body to. The error message itself should actually tell you which function it is.
Can you post the actual error message instead of just summarizing it?
1>------ Build started: Project: PGM5, Configuration: Debug Win32 ------
1> MedinaL_PGM5.cpp
1>MedinaL_PGM5.cpp(26): warning C4101: 'distance' : unreferenced local variable
1>c:\users\luis\documents\visual studio 2013\projects\pgm5\medinal_pgm5.cpp(105): warning C4715: 'CheckChutes' : not all control paths return a value
1>c:\users\luis\documents\visual studio 2013\projects\pgm5\medinal_pgm5.cpp(121): warning C4715: 'CheckLadders' : not all control paths return a value
1>c:\users\luis\documents\visual studio 2013\projects\pgm5\medinal_pgm5.cpp(35): warning C4700: uninitialized local variable 'position' used
1>c:\users\luis\documents\visual studio 2013\projects\pgm5\medinal_pgm5.cpp(36): warning C4700: uninitialized local variable 'newPosition' used
1>c:\users\luis\documents\visual studio 2013\projects\pgm5\medinal_pgm5.cpp(36): warning C4700: uninitialized local variable 'die' used
1>c:\users\luis\documents\visual studio 2013\projects\pgm5\medinal_pgm5.cpp(36): warning C4700: uninitialized local variable 'turn' used 1>MedinaL_PGM5.obj : error LNK2028: unresolved token (0A000473) "int __cdecl RollDice(void)" (?RollDice@@$$FYAHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>MedinaL_PGM5.obj : error LNK2019: unresolved external symbol "int __cdecl RollDice(void)" (?RollDice@@$$FYAHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>C:\Users\Luis\documents\visual studio 2013\Projects\PGM5\Debug\PGM5.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I bolded what I believe to be the problem, I'm just not sure how I'd go about resolving this.