Please help. It gives me two errors when I compile:
1. Unresolved external symbol "void __cdelc dodrop(int)...
2. Fatal Error. 1 Unresolved Externals
Here is the code:
#include <iostream.h>
#include <windows.h>
#include <conio.h>
#define BLK 0
#define RED 1
#define NON 2
#define DRW 3
#define LEFT 0x4B
#define RIGHT 0x4D
#define UP 0x48
#define DOWN 0x50
#define ESC 0x1B
#define ENTER 0x0D
#define PLAYER 0x0001 & turn
void initialize(void);
void gotoxy(int x, int y);
void drawboard(void);
void drawtop(void);
void clrtop(void);
void dodrop(int col);
void checkwin(int col,int row);
void settextcolor(int c);
char board[8][8];
int pos[2] = { 1 , 15 };
int color[2] = { 8 , 12 };
char turn;
char string[128];
int win;
HANDLE hConsole;
int main(void)
{
char inkey;
do
{
initialize();
drawboard();
clrtop();
do
{
drawtop();
do
{
inkey = _getch();
if(inkey == NULL)
{
inkey = _getch();
switch(inkey)
{
case LEFT :
if(pos[PLAYER] > 1)
{
gotoxy(pos[PLAYER],0);
cout << " ";
pos[PLAYER] -= 2;
settextcolor(color[PLAYER]);
gotoxy(pos[PLAYER],0);
cout << "*";
}
break;
case RIGHT :
if(pos[PLAYER] < 15)
{
gotoxy(pos[PLAYER],0);
cout << " ";
pos[PLAYER] += 2;
settextcolor(color[PLAYER]);
gotoxy(pos[PLAYER],0);
cout << "*";
}
break;
case DOWN :
if(board[0][(pos[PLAYER]-1) >> 1] == NON)
{
dodrop((pos[PLAYER]-1)>>1);
inkey = ENTER;
}
else
{
inkey = NULL;
}
break;
}
}
else if(inkey == ENTER)
{
if(board[0][(pos[PLAYER]-1) >> 1] == NON)
{
dodrop((pos[PLAYER]-1)>>1);
}
else
{
inkey = NULL;
}
}
} while(inkey != ESC && inkey != ENTER && win == NON);
clrtop();
turn++;
} while(inkey != ESC && turn < 64 && win == NON);
settextcolor(15);
switch(win)
{
case BLK:
gotoxy(0,0);
cout << "Black won";
break;
case RED:
gotoxy(0,0);
cout << "Red won";
break;
case DRW:
gotoxy(0,0);
cout << "Draw";
break;
default:
gotoxy(0,0);
cout << "Nobody won";
}
gotoxy(0,20);
cout << "(press ESC to exit, any key to replay)";
inkey = _getch();
gotoxy(0,20);
cout << " ";
} while(inkey != ESC);
return(0);
}
void drawboard(void)
{
int row,col;
gotoxy(0,2);
settextcolor(14);
cout << "+-+-+-+-+-+-+-+-+\n";
for(row = 0;row < 8;row++)
{
for(col = 0;col < 8;col++)
{
cout << "|";
if(board[row][col] != NON)
{
settextcolor(color[board[row][col]]);
cout << "*";
settextcolor(14);
}
else
{
cout << " ";
}
}
cout << "|\n+-+-+-+-+-+-+-+-+\n";
}
}
void initialize(void)
{
int count1,count2;
struct _CONSOLE_CURSOR_INFO PCONSOLE_CURSOR_INFO;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for(count1 = 0;count1 < 8;count1++)
{
for(count2 = 0;count2 < 8;count2++)
{
board[count1][count2] = (char)NON;
}
}
turn = 0;
win = NON;
PCONSOLE_CURSOR_INFO.dwSize = 1;
PCONSOLE_CURSOR_INFO.bVisible = FALSE;
SetConsoleCursorInfo(hConsole,&PCONSOLE_CURSOR_INFO);
}
void settextcolor(int c)
{
SetConsoleTextAttribute(hConsole, c);
}
void gotoxy(int x, int y)
{
COORD dwCursorPosition;
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
SetConsoleCursorPosition(hConsole,dwCursorPosition);
}
void clrtop(void)
{
gotoxy(0,0);
cout << " ";
}
void drawtop(void)
{
settextcolor(color[PLAYER]);
gotoxy(pos[PLAYER],0);
cout << "*";
}
void checkwin(int col,int row)
{
int pieces,counter;
pieces = 0;
counter = 0;
do
{
pieces++;
counter++;
} while(((row+counter) < 8) && (board[row+counter][col] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
pieces = 0;
counter = 0;
do
{
pieces++;
counter--;
} while(((col+counter) > -1) && (board[row][col+counter] == ( PLAYER )));
counter = 0;
pieces--;
do
{
pieces++;
counter++;
} while(((col+counter) < 8) && (board[row][col+counter] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
pieces = 0;
counter = 0;
do
{
pieces++;
counter--;
} while(((col+counter) > -1) && ((row+counter) > -1) && (board[row+counter][col+counter] == ( PLAYER )));
counter = 0;
pieces--;
do
{
pieces++;
counter++;
} while(((col+counter) < 8) && ((row+counter) < 8) && (board[row+counter][col+counter] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
pieces = 0;
counter = 0;
do
{
pieces++;
counter--;
} while(((col+counter) > -1) && ((row+(-1*counter)) < 8) && (board[row+(-1*counter)][col+counter] == ( PLAYER )));
counter = 0;
pieces--;
do
{
pieces++;
counter++;
} while(((col+counter) < 8) && ((row+(-1*counter)) < 8) && (board[row+(-1*counter)][col+counter] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
if(turn == 63)
{
win = DRW;
}
}
1. Unresolved external symbol "void __cdelc dodrop(int)...
2. Fatal Error. 1 Unresolved Externals
Here is the code:
#include <iostream.h>
#include <windows.h>
#include <conio.h>
#define BLK 0
#define RED 1
#define NON 2
#define DRW 3
#define LEFT 0x4B
#define RIGHT 0x4D
#define UP 0x48
#define DOWN 0x50
#define ESC 0x1B
#define ENTER 0x0D
#define PLAYER 0x0001 & turn
void initialize(void);
void gotoxy(int x, int y);
void drawboard(void);
void drawtop(void);
void clrtop(void);
void dodrop(int col);
void checkwin(int col,int row);
void settextcolor(int c);
char board[8][8];
int pos[2] = { 1 , 15 };
int color[2] = { 8 , 12 };
char turn;
char string[128];
int win;
HANDLE hConsole;
int main(void)
{
char inkey;
do
{
initialize();
drawboard();
clrtop();
do
{
drawtop();
do
{
inkey = _getch();
if(inkey == NULL)
{
inkey = _getch();
switch(inkey)
{
case LEFT :
if(pos[PLAYER] > 1)
{
gotoxy(pos[PLAYER],0);
cout << " ";
pos[PLAYER] -= 2;
settextcolor(color[PLAYER]);
gotoxy(pos[PLAYER],0);
cout << "*";
}
break;
case RIGHT :
if(pos[PLAYER] < 15)
{
gotoxy(pos[PLAYER],0);
cout << " ";
pos[PLAYER] += 2;
settextcolor(color[PLAYER]);
gotoxy(pos[PLAYER],0);
cout << "*";
}
break;
case DOWN :
if(board[0][(pos[PLAYER]-1) >> 1] == NON)
{
dodrop((pos[PLAYER]-1)>>1);
inkey = ENTER;
}
else
{
inkey = NULL;
}
break;
}
}
else if(inkey == ENTER)
{
if(board[0][(pos[PLAYER]-1) >> 1] == NON)
{
dodrop((pos[PLAYER]-1)>>1);
}
else
{
inkey = NULL;
}
}
} while(inkey != ESC && inkey != ENTER && win == NON);
clrtop();
turn++;
} while(inkey != ESC && turn < 64 && win == NON);
settextcolor(15);
switch(win)
{
case BLK:
gotoxy(0,0);
cout << "Black won";
break;
case RED:
gotoxy(0,0);
cout << "Red won";
break;
case DRW:
gotoxy(0,0);
cout << "Draw";
break;
default:
gotoxy(0,0);
cout << "Nobody won";
}
gotoxy(0,20);
cout << "(press ESC to exit, any key to replay)";
inkey = _getch();
gotoxy(0,20);
cout << " ";
} while(inkey != ESC);
return(0);
}
void drawboard(void)
{
int row,col;
gotoxy(0,2);
settextcolor(14);
cout << "+-+-+-+-+-+-+-+-+\n";
for(row = 0;row < 8;row++)
{
for(col = 0;col < 8;col++)
{
cout << "|";
if(board[row][col] != NON)
{
settextcolor(color[board[row][col]]);
cout << "*";
settextcolor(14);
}
else
{
cout << " ";
}
}
cout << "|\n+-+-+-+-+-+-+-+-+\n";
}
}
void initialize(void)
{
int count1,count2;
struct _CONSOLE_CURSOR_INFO PCONSOLE_CURSOR_INFO;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for(count1 = 0;count1 < 8;count1++)
{
for(count2 = 0;count2 < 8;count2++)
{
board[count1][count2] = (char)NON;
}
}
turn = 0;
win = NON;
PCONSOLE_CURSOR_INFO.dwSize = 1;
PCONSOLE_CURSOR_INFO.bVisible = FALSE;
SetConsoleCursorInfo(hConsole,&PCONSOLE_CURSOR_INFO);
}
void settextcolor(int c)
{
SetConsoleTextAttribute(hConsole, c);
}
void gotoxy(int x, int y)
{
COORD dwCursorPosition;
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
SetConsoleCursorPosition(hConsole,dwCursorPosition);
}
void clrtop(void)
{
gotoxy(0,0);
cout << " ";
}
void drawtop(void)
{
settextcolor(color[PLAYER]);
gotoxy(pos[PLAYER],0);
cout << "*";
}
void checkwin(int col,int row)
{
int pieces,counter;
pieces = 0;
counter = 0;
do
{
pieces++;
counter++;
} while(((row+counter) < 8) && (board[row+counter][col] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
pieces = 0;
counter = 0;
do
{
pieces++;
counter--;
} while(((col+counter) > -1) && (board[row][col+counter] == ( PLAYER )));
counter = 0;
pieces--;
do
{
pieces++;
counter++;
} while(((col+counter) < 8) && (board[row][col+counter] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
pieces = 0;
counter = 0;
do
{
pieces++;
counter--;
} while(((col+counter) > -1) && ((row+counter) > -1) && (board[row+counter][col+counter] == ( PLAYER )));
counter = 0;
pieces--;
do
{
pieces++;
counter++;
} while(((col+counter) < 8) && ((row+counter) < 8) && (board[row+counter][col+counter] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
pieces = 0;
counter = 0;
do
{
pieces++;
counter--;
} while(((col+counter) > -1) && ((row+(-1*counter)) < 8) && (board[row+(-1*counter)][col+counter] == ( PLAYER )));
counter = 0;
pieces--;
do
{
pieces++;
counter++;
} while(((col+counter) < 8) && ((row+(-1*counter)) < 8) && (board[row+(-1*counter)][col+counter] == ( PLAYER )));
if(pieces > 3)
{
win = PLAYER;
return;
}
if(turn == 63)
{
win = DRW;
}
}