Well heres my code, I've spent about an hour trying to iron out the errors, I got most of 'em but these two still elude me. I don't know if this will even work yet, as I haven't gotten it to compile yet. Any help would be appreciated.
Code:
Errors:
--------------------Configuration: tictac - Win32 Debug--------------------
Compiling...
tictac.cpp
C:\Windows\Desktop\TicTac\tictac.cpp(23) : error C2660: 'setCoords' : function does not take 0 parameters
C:\Windows\Desktop\TicTac\tictac.cpp(51) : error C2660: 'checkWin' : function does not take 0 parameters
Error executing cl.exe.
tictac.obj - 2 error(s), 0 warning(s)
Code:
Code:
#include <iostream.h>
#include <windows.h> //for system("CLS");
//VARIABLE DEFINITIONS AND PROTOTYPES
void title(void);
void key(void);
void printNames(void);
void printTable(void);
bool checkWin(bool player);
int setCoords(int x, int y, bool player);
int getInput(void);
char board[3][3];
bool whichplayermove;
char name1[50];
char name2[50];
short int i;
short int ii;
short int x,y;
short int moves;
char input;
char playagain;
int didassigncoords = setCoords();
//END VARS AND PROTOS
int main(void)
{
title();
printNames();
getInput();
setCoords(x, y, whichplayermove);
if (didassigncoords == 0)
{
checkWin(whichplayermove);
if (checkWin(whichplayermove) == 1)
{
if (whichplayermove == 0) {whichplayermove++;}
if (whichplayermove == 1) {whichplayermove = 0;}
moves++;
if (moves == 9)
{
cout << "No winner this time! Play again? (Y/N)->";
cin>>playagain;
if (playagain == 'Y' || playagain == 'y') { main();} else { return 0;}
}
else
{
getInput();
}
}
if (checkWin() == 0)
{
cout << "Congrats! Play again? (Y/N)->";
cin>>playagain;
if (playagain == 'Y' || playagain == 'y') { main();} else { return 0;}
}
}
}
bool checkWin(bool player)
{
//CHECK ROWS
if ((board[0][0] == board[0][1] && board[0][1] == board[0][2]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
if ((board[1][0] == board[1][1] && board[1][1] == board[1][2]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
if ((board[2][0] == board[2][1] && board[2][1] == board[2][2]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
//CHECK COLUMNS
if ((board[0][0] == board[1][0] && board[1][0] == board[2][0]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
if ((board[0][1] == board[1][1] && board[1][1] == board[2][1]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
if ((board[0][2] == board[1][2] && board[1][2] == board[2][2]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
//CHECK DIAGONALS
if ((board[0][2] == board[1][1] && board[1][1] == board[2][2]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
if ((board[2][0] == board[1][1] && board[1][1] == board[0][2]) != '*')
{
cout<<"You've won Player "<<player<<".\n";
return 0;
}
return 1;
}
void title()
{
cout <<"+-+-+ +-+-+ +--+ +-+-+ +--+ +--+ +-+-+ +--+ +--+";
cout <<" | | | | |__| | | | | |__ ";
cout <<" | | | | | | | | | | | ";
cout <<" + +-+-+ +--+ + + + +--+ + +--+ +--+";
cout <<"\n";
cout <<"By: Dual-Catfish ([email protected]) ";
}
void key(void)
{
cout<<"-----------\n";
cout<<"(1) (2) (3)\n";
cout<<"(4) (5) (6)\n";
cout<<"(7) (8) (9)\n";
cout<<"-----------\n";
}
void printNames(void)
{
cout << "Enter your name player 1->";
cin.getline(name1, 50, '\n');
cout << "\n";
cout << "Enter your name player 2->";
cin.getline(name2, 50, '\n');
for (i=0;i<3;i++)
{
board[i][0]='*';
board[0][i]='*';
for (ii=0;ii<3;ii++)
{
board[i][ii]='*';
}
}
}
void printTable(void)
{
cout << "+---+---+---+" <<endl;
cout << "|"<<board[0][0]<<"|"<<board[0][1]<<"|"<<board[0][2]<<"|" <<endl;
cout << "+---+---+---+" <<endl;
cout << "|"<<board[1][0]<<"|"<<board[1][1]<<"|"<<board[1][2]<<"|" <<endl;
cout << "+---+---+---+" <<endl;
cout << "|"<<board[2][0]<<"|"<<board[2][1]<<"|"<<board[2][2]<<"|" <<endl;
cout << "+---+---+---+" <<endl;
}
int setCoords(int x, int y, bool player)
{
if (board[x][y] == '*')
{
if (whichplayermove == 0) {
board[x][y] = 'X';
return 0;
}else{
board[x][y] = 'O';
return 0;
}
}else{
cout << "That move has already been made.\n";
getInput();
return 1;
}
}
int getInput(void)
{
printTable();
cout << "\nMake your move Player " << whichplayermove+1 << ". (Refer to below key)\n";
key();
cout << "Move->";
cin>>input;
switch (input)
{
case '1': { x = 0; y = 0; break; }
case '2': { x = 0; y = 1; break; }
case '3': { x = 0; y = 2; break; }
case '4': { x = 1; y = 0; break; }
case '5': { x = 1; y = 1; break; }
case '6': { x = 1; y = 2; break; }
case '7': { x = 2; y = 0; break; }
case '8': { x = 2; y = 1; break; }
case '9': { x = 2; y = 2; break; }
{
cout << "Invalid input, please restate.\n";
getInput();
}
}
system("CLS");
return 0;