Question: This is the error message I get when I compile my code This is the source code, I can provide all my code if it

This is the error message I get when I compile my code

This is the error message I get when I compile my code

This is the source code, I can provide all my code if it helps

This is the source code, I can provide all my code if

ENTIRE SOURCE CODE:

#include #include #include #include

// Initializing board void clear_table(char board [3][3]) { int i, j;

//Outer loop for rows for(i=0; i

// prints the board in nice format void display_table (char board [3][3]) { int i, j;

printf(" The board is: ");

printf(" |---|---|---| ");

//Outer loop for rows for(i=0; i

printf(" |");

//Printing footer printf(" |---|---|---| "); } }

//Function that generates a valid move for player 2 void generate_player2_move(char board[3][3], int* row, int *col) { //Validating move while(1) { //Generating computer position *row = rand() % 3; *col = rand() % 3;

//Checking for empty position if(check_legal_option(board, *row, *col) == 1) break; } }

//Function that checks whether board is full or not int check_table_full(char board[3][3]) { int i, j;

//Outer loop for rows for(i=0; i

//Board Full return 1; }

// win returns true if the given player has won on the // given board, else it returns false int win (char board [3][3], char player) { return (board[0][0] == player && board[0][1] == player && board[0][2] == player) || (board[1][0] == player && board[1][1] == player && board[1][2] == player) || (board[2][0] == player && board[2][1] == player && board[2][2] == player) || (board[0][0] == player && board[1][0] == player && board[2][0] == player) || (board[0][1] == player && board[1][1] == player && board[2][1] == player) || (board[0][2] == player && board[1][2] == player && board[2][2] == player) || (board[0][0] == player && board[1][1] == player && board[2][2] == player) || (board[0][2] == player && board[1][1] == player && board[2][0] == player);

}

//Function that checks for winner int check_three_in_a_row(char board[3][3], char player1, char player2) { //Checking for winning of player if(win(board, 'X') == 1 && win(board, 'O') == 1) { return 2; } //Checking for winning of player 1 else if(win(board, 'O') == 1) { return 0; } //Checking for winning of player 2 else if(win(board, 'X') == 1) { return 1; } //Tie else { return -1; } }

//Validates the move int check_legal_option(char board[3][3], int row, int col) { //Checking position if(board[row][col] == ' ') { //Available return 1; }

return 0; }

//Function that plays the game void playGame(char board[3][3], char player1, char player2) { int row, col; int winner;

//Loop till board is full while(check_table_full(board) != 1) { //Player turn while(1) { //Reading positions from user printf(" Player 1 enter your selection [row,col]: "); scanf("%d %d", &row, &col);

//Making suitable for array indexing row = row - 1; col = col - 1;

//Checking for empty position if(check_legal_option(board, row, col) == 1) break; else printf(" Invalid choice... Try again!! "); }

//Storing in array board[row][col] = player1;

//Printing board display_table(board);

//Finding winner winner = check_three_in_a_row(board, player1, player2);

//If either of winner is found if(winner >= 0 && winner

return; }

//Generating a move generate_player2_move(board, &row, &col);

//Storing in array board[row][col] = player2;

printf(" Player 2 has entered [row,col]: %d,%d ", row+1, col+1);

//Printing board display_table(board);

//Finding winner winner = check_three_in_a_row(board, player1, player2);

//If either of winner is found if(winner >= 0 && winner

return; } } }

//Main function int main() { //Board char board[3][3];

//Player characters char player1Character='O', player2Character='X';

//Initializing random function srand(time(NULL));

//Initializing board clear_table(board);

//Printing board display_table(board);

//Playing game playGame(board, player1Character, player2Character);

return 0; }

tictactoe.c: In function 'generate_player2_move': tictactoe . c : 59:12: warning: implicit declaration of function check-legal-option [-Wimplicit-function-declaration] if (check_legal_option (board, *row, *col) -1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!