Hi, I am having a weird problem with my compiler; After finally straightening my code out for a tic tac toe game(which I was having trouble with in the first place, so it is using VERY primitive techniques...but anyway, that's not the point) So after I fixed all the code errors, I get this error when the compiler goes to the linking stage; Here is the message
I have NO IDEA what in the heck this means, so some help would be greatly appreciated...Code:------ Build started: Project: ttttest, Configuration: Debug Win32 ------
Compiling...
source2.cpp
Linking...
source2.obj : error LNK2019: unresolved external symbol "void __cdecl board(int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?board@@YAXHHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\ttttest\Debug\ttttest.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\ttttest\ttttest\Debug\BuildLog.htm"
ttttest - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Umm, not sure if this is legal, but here is my source code as well...(it's 183 lines!)
Code:#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
void clrscr();
void board(int, int, string);
int main()
{
int x, y, player;
string v;
string xy[3][3];
player = 1;
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3 \n\n";
cout << "\t\t1[ ][ ][ ]\n";
cout << "\t\t2[ ][ ][ ]\n";
cout << "\t\t3[ ][ ][ ]\n";
cout << "Player " << player << ", enter the number of the row and then the column you wish to move to: ";
cin >> x;
cout << endl;
cin >> y;
if (player==1)
{
if (xy[x][y]=="o")
{
cout << "That square is taken by the other player";
main();
}
else if (xy[x][y]=="x")
{
cout << "That square is take by you!";
main();
}
else
{
xy[x][y]="x";
board(x, y, xy[3][3]);
player=2;
clrscr();
}
}
else if (player==2)
{
if (xy[x][y]=="x")
{
cout << "That square is taken by the other player";
main();
}
else if (xy[x][y]=="o")
{
cout << "That square is take by you!";
main();
}
else
{
xy[x][y]="o";
board(x, y, xy[3][3]);
player=1;
clrscr();
}
}
return 0;
}
void clrscr() //Clears the screen
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
void board(int x, int y, string xy[3][3])
{
string f;
f = xy[x][y] ;
if (x==1)
{
if (y==1)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 ["<<f<<"][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
}
else if (y==2)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ]["<<f<<"][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
}
else if (y==3)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ][ ]["<<f<<"]\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
}
}
else if (x==2)
{
if (y==1)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 ["<<f<<"][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
}
else if (y==2)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ]["<<f<<"][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
}
else if (y==3)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ]["<<f<<"]\n";
cout << "\t\t1 [ ][ ][ ]\n";
}
}
else if (x==3)
{
if (y==1)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 ["<<f<<"][ ][ ]\n";
}
else if (y==2)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ]["<<f<<"][ ]\n";
}
else if (y==3)
{
cout << "\t\t__TIC-TAC-TOE__\n";
cout << "\t\tTwo Player Game\n\n";
cout << "\t\t 1 2 3\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ][ ]\n";
cout << "\t\t1 [ ][ ]["<<f<<"]\n";
}
}
else
{
cout << "Some sort of error occurred!";
}
}