void player2_move (void){
  srand(time(NULL));
  int i = rand() % 3;
  int j = rand() % 3;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++)
      if (matrix[i][j] == ' ') 
        break;
    if (matrix[i][j] == ' ')
      break;
  }
  if (i * j == 9)
  {
    printf ("Neither player wins\n"); 
    exit (0);
  }
  else
    matrix[i][j] = 'X';
}
This is for Homework
I have to make a game of TicTacToe and the issue I'm having is how to have the computer have randomized moves against the player. When I compile the computer just ends up choosing the same moves every game. How do I make this completely random? Ill attach a picture of what the compiler is showing.
The program is still a work in progress-so the product is still a bit messy
 
    