dimanche 19 février 2023

Variable undeclared with random in c

I don't why it gives me l and col as undeclared inside this function.

I had written srand(time(null)) in main and I have already used rand in other variable in main and in this function, it's the second time using it.

void joueur_ordinateur(char jeton, int *a) {
  srand(time(NULL));
  do {
    int l = rand() % 9;
    int col = rand() % 9;
  } while (matrice[l][col] == '.');

  matrice[l][col] = jeton;
  for (int i = 0; i < DIMENSION; i++) {
    for (int j = 0; j < DIMENSION; j++)
      copie[i][j] = matrice[i][j];
  }

  for (int i = 0; i < DIMENSION; i++) {
    for (int j = 0; j < DIMENSION; j++) {
      capture_chaine(i, j, jeton, a);
    }
  }

  printf("\n");
}



Aucun commentaire:

Enregistrer un commentaire