Tic tac toe – Unbeatable Tic-Tac-Toe command line written in C, where the user must start first by "x". or second by & # 39; o & # 39;

One of my first projects in C. I'm trying to learn programming and this Tic-Tac-Toe is one of my first projects. Give me some reviews about the code and suggestions for improving the structure and style. Any suggestions for future projects that may improve my programming skills are also welcome.

#understand 
#define MAX (x, y) (((x)> (y))? (x): (y)
#define MIN (x, y) (((x) <(y))? (x): (y))
/ * the print function will be called after each entry of the user * /
empty print (because (* GRID)[7])
{
/ * The length and width of the grid of a tic-tac-toe game is 3 * 3 * /
int length = 7, width = 7, i, j;
printf (" nTic-Tac-Toe of Udhay Sankar  n  n");
for (i = 0; i <length; i ++)
{
printf ("");
for (j = 0; j0) && ((TEMP1) <10))
{
switch (TEMP1)
{
case 1:
if (GRILLE[1][1]==> x & # 39; || WIRE RACK[1][1]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 2:
if (GRILLE[1][3]==> x & # 39; || WIRE RACK[1][3]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 3:
if (GRILLE[1][5]==> x & # 39; || WIRE RACK[1][5]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 4:
if (GRILLE[3][1]==> x & # 39; || WIRE RACK[3][1]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 5:
if (GRILLE[3][3]==> x & # 39; || WIRE RACK[3][3]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 6:
if (GRILLE[3][5]==> x & # 39; || WIRE RACK[3][5]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 7:
if (GRILLE[5][1]==> x & # 39; || WIRE RACK[5][1]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 8:
if (GRILLE[5][3]==> x & # 39; || WIRE RACK[5][3]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
case 9:
if (GRILLE[5][5]==> x & # 39; || WIRE RACK[5][5]== & # 39; o & # 39;)
{
printf (" nPosition already occupied !!!  n");
returns 0;
}
other
returns 1;
Pause;
}
}
other
{
returns 0;
}
}
/ * function to get the input of the user * /
void get_input (char (* GRID)[7], int tour)
{
int TEMP2;
if (1 == turn)
{
printf (" nConsider the 3 * 3 grid with 9 positions  n  nIf the position is line 2, column 3, enter 6 as input  n  nEnter your position for" x ":");
}
other
{
printf (" nConsider the 3 * 3 grid with 9 positions  n  nIf the position is line 2, column 3, enter 6 as input  n  nEnter your position for" o ":");
}
scanf ("% d", & TEMP2);
while ((valid (GRID, TEMP2))! = 1)
{
// if the position is already occupied
printf (" nInvalid Entry! Enter a valid location  n");
if (1 == turn)
{
printf (" nConsider the 3 * 3 grid with 9 positions  n  nIf the position is line 2, column 3, enter 6 as input  n  nEnter your position for" x ":");
}
other
{
printf (" nConsider the 3 * 3 grid with 9 positions  n  nIf the position is line 2, column 3, enter 6 as input  n  nEnter your position for" o ":");
}
scanf ("% d", & TEMP2);
}
if (1 == turn)
{
switch (TEMP2)
{
case 1: grid[1][1]= X & # 39 ;;
Pause;
case 2: grid[1][3]= X & # 39 ;;
Pause;
case 3: GRID[1][5]= X & # 39 ;;
Pause;
case 4: grid[3][1]= X & # 39 ;;
Pause;
case 5: grid[3][3]= X & # 39 ;;
Pause;
case 6: grid[3][5]= X & # 39 ;;
Pause;
case 7: grid[5][1]= X & # 39 ;;
Pause;
case 8: grid[5][3]= X & # 39 ;;
Pause;
case 9: grid[5][5]= X & # 39 ;;
Pause;
}
}
other
{
switch (TEMP2)
{
case 1: grid[1][1]= & # 39; o;
Pause;
case 2: grid[1][3]= & # 39; o;
Pause;
case 3: GRID[1][5]= & # 39; o;
Pause;
case 4: grid[3][1]= & # 39; o;
Pause;
case 5: grid[3][3]= & # 39; o;
Pause;
case 6: grid[3][5]= & # 39; o;
Pause;
case 7: grid[5][1]= & # 39; o;
Pause;
case 8: grid[5][3]= & # 39; o;
Pause;
case 9: grid[5][5]= & # 39; o;
Pause;
}
}
}
// function to find the number of available_spots available
int available_spots (char (* GRID)[7])
{
int spots = 0;
for (int i = 1; i <6; i = i + 2)
for (int j = 1; j <6; j = j + 2)
{
if (GRILLE[i][j]== & # 39;)
spots ++;
}
return points;
}
// function to check the gain condition after each move of the user and the computer
int terminal_state (char (* GRID)[7])
{
if (((GRID[1][1]== o & # 39;) && (GRID[1][3]== & # 39;)) && ((GRID[1][3]== o & # 39;) && (GRID[1][5]== & # 39; o & # 39;)
{
return -10;
}
if not ((((GRID[3][1]== o & # 39;) && (GRID[3][3]== & # 39;)) && ((GRID[3][3]== o & # 39;) && (GRID[3][5]== & # 39; o & # 39;)
{
return -10;
}
if not ((((GRID[5][1]== o & # 39;) && (GRID[5][3]== & # 39;)) && ((GRID[5][3]== o & # 39;) && (GRID[5][5]== & # 39; o & # 39;)
{
return -10;
}
if not ((((GRID[1][1]== o & # 39;) && (GRID[3][1]== & # 39;)) && ((GRID[3][1]== o & # 39;) && (GRID[5][1]== & # 39; o & # 39;)
{
return -10;
}
if not ((((GRID[1][3]== o & # 39;) && (GRID[3][3]== & # 39;)) && ((GRID[3][3]== o & # 39;) && (GRID[5][3]== & # 39; o & # 39;)
{
return -10;
}
if not ((((GRID[1][5]== o & # 39;) && (GRID[3][5]== & # 39;)) && ((GRID[3][5]== o & # 39;) && (GRID[5][5]== & # 39; o & # 39;)
{
return -10;
}
if not ((((GRID[1][1]== o & # 39;) && (GRID[3][3]== & # 39;)) && ((GRID[3][3]== o & # 39;) && (GRID[5][5]== & # 39; o & # 39;)
{
return -10;
}
if not ((((GRID[1][5]== o & # 39;) && (GRID[3][3]== & # 39;)) && ((GRID[3][3]== o & # 39;) && (GRID[5][1]== & # 39; o & # 39;)
{
return -10;
}
if (((GRID[1][1]== x & # 39;) && (GRID[1][3]== x & # 39;)) && ((GRID[1][3]== x & # 39;) && (GRID[1][5]==> x ')))
{
returns 10;
}
if not ((((GRID[3][1]== x & # 39;) && (GRID[3][3]== x & # 39;)) && ((GRID[3][3]== x & # 39;) && (GRID[3][5]==> x ')))
{
returns 10;
}
if not ((((GRID[5][1]== x & # 39;) && (GRID[5][3]== x & # 39;)) && ((GRID[5][3]== x & # 39;) && (GRID[5][5]==> x ')))
{
returns 10;
}
if not ((((GRID[1][1]== x & # 39;) && (GRID[3][1]== x & # 39;)) && ((GRID[3][1]== x & # 39;) && (GRID[5][1]==> x ')))
{
returns 10;
}
if not ((((GRID[1][3]== x & # 39;) && (GRID[3][3]== x & # 39;)) && ((GRID[3][3]== x & # 39;) && (GRID[5][3]==> x ')))
{
returns 10;
}
if not ((((GRID[1][5]== x & # 39;) && (GRID[3][5]== x & # 39;)) && ((GRID[3][5]== x & # 39;) && (GRID[5][5]==> x ')))
{
returns 10;
}
if not ((((GRID[1][1]== x & # 39;) && (GRID[3][3]== x & # 39;)) && ((GRID[3][3]== x & # 39;) && (GRID[5][5]==> x ')))
{
returns 10;
}
if not ((((GRID[1][5]== x & # 39;) && (GRID[3][3]== x & # 39;)) && ((GRID[3][3]== x & # 39;) && (GRID[5][1]==> x ')))
{
returns 10;
}
else if (available_spots (GRID) == 0)
returns 0;
}
/ * function of minimax algorithm that is recursive * /
int minimax (because (* GRID)[7], int tour)
{
//
int best;
if (terminal_state (GRID) == 10)
returns 10;
if (terminal_state (GRID) == - 10)
return -10;
if (terminal_state (GRID) == 0)
returns 0;
//
if (0 == turn)
{
int i, j;
int temp;
best = 1000;
for (int i = 1; i <6; i = i + 2)
{
for (int j = 1; j <6; j = j + 2)
{
if (GRILLE[i][j]== & # 39;)
{
GRID[i][j]= & # 39; o;
temp = minimax (GRID, 1);
best = MIN (temp, best);
GRID[i][j]= & # 39 ;;
}
}
}
best return;
}
if not (1 == turn)
{
int i, j;
int temp;
best = -1000;
for (i = 1; i <6; i = i + 2)
{
for (j = 1; j <6; j = j + 2)
{
if (GRILLE[i][j]== & # 39;)
{
GRID[i][j]= X & # 39 ;;
temp = minimax (GRID, 0);
best = MAX (temp, best);
GRID[i][j]= & # 39 ;;
}
}
}
best return;
}
}
// the following function returns the best move
void computer_position (char (* GRID)[7], int tour)
{
if (0 == turn)
{
int sample = 1000;
int computer_move[3];
computer_move[0]= sample;
for (int i = 1; i <6; i = i + 2)
{
for (int j = 1; j <6; j = j + 2)
{
if (GRILLE[i][j]== & # 39;)
{
GRID[i][j]= & # 39; o;
sample = minimax (GRID,! turn);
if (example <computer_move[0])
{
computer_move[0]= sample;
computer_move[1]= i;
computer_move[2]= j;
}
GRID[i][j]= & # 39 ;;
}
}
}
GRID[computer_move[computer_move[computer_move[computer_move[1]][computer_move[computer_move[computer_move[computer_move[2]]= & # 39; o;
}
other
{
int sample = -1000;
int computer_move[3];
computer_move[0]= sample;
for (int i = 1; i <6; i = i + 2)
{
for (int j = 1; j<6;j=j+2)
      {
        if(GRID[i][j]==' ')
        {
          GRID[i][j]='x';
          sample=minimax(GRID,!turn);
          if(sample>computer_move[0])
{
computer_move[0]= sample;
computer_move[1]= i;
computer_move[2]= j;
}
GRID[i][j]= & # 39 ;;
}
}
}
GRID[computer_move[computer_move[computer_move[computer_move[1]][computer_move[computer_move[computer_move[computer_move[2]]= X & # 39 ;;
}
}
/*main function*/
int main ()
{
// int USR_INPUT, RESULT;
tank grill[7][7]= {
- "-" - "-" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , & # 39;; & # 39; - & # 39;
(& # 39;), & # 39;, & # 39;, & # 39; & # 39;, & # 39; ", # 39; & # 39;},
- "-" - "-" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , & # 39;; & # 39; - & # 39;
(& # 39;), & # 39;, & # 39;, & # 39; & # 39;, & # 39; ", # 39; & # 39;},
- "-" - "-" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , & # 39;; & # 39; - & # 39;
(& # 39;), & # 39;, & # 39;, & # 39; & # 39;, & # 39; ", # 39; & # 39;},
- "-" - "-" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , & # 39; - & # 39; - & # 39;
};
int tour;
// take the turn of the user
printf (" nDo you want to start with" x "or" o "?  n");
printf (" nEnter 1 for" x or 0 for ":");
scanf ("% d", & turn);
while ((turn! = 0) && (turn! = 1))
{
printf (" nOne invalid value to turn!  n");
printf (" nDo you want to start with" x "or" o "?  n");
printf (" nEnter 1 for" x or 0 for ":");
scanf ("% d", & turn);
}
// when no place is available or only one victory condition is obtained
if (1 == turn)
{
while (available_spots (GRID)! = 0)
{
print (GRID);
get_input (GRID, turn);
if (terminal_state (GRID) == 10)
{
print (GRID);
printf (" nYou won  n  n");
returns 0;
} else if (terminal_state (GRID) == - 10) {
print (GRID);
printf (" nL & # 39; computer won  n  n");
returns 0;
} else if (terminal_state (GRID) == 0) {
print (GRID);
printf (" nThe game is a draw  n  n");
returns 0;
}
computer_position (GRID,! turn);
}
}
other
{
while (available_spots (GRID)! = 0)
{
computer_position (GRID,! turn);
if (terminal_state (GRID) == - 10)
{
print (GRID);
printf (" nYou won  n  n");
returns 0;
} else if (terminal_state (GRID) == 10) {
print (GRID);
printf (" nL & # 39; computer won  n  n");
returns 0;
} else if (terminal_state (GRID) == 0) {
print (GRID);
printf (" nThe game is a draw  n  n");
returns 0;
}
print (GRID);
get_input (GRID, turn);
}
}
}