I am doing a game in C, I have a board with dimensions generated by the user, where the Xs are the randomly generated 'trees', I am trying to enter the players J1 and J2 who would be who are going to play, I want it in opposite corners, for example if the board is 9x9, J1 should be at 9a and J2 at 1i.
I tried putting tablero[i = TamTablero] [j = 0] = 'J1' in the code, but that didn't work. And the same for J2. I've been stuck here for quite a while.
Here is my code, where TamTablero means BoardSize:
int main() {
int TamTablero=0;
printf("Ingrese el area del bosque donde va a jugar: ");
scanf("%d", &TamTablero);
char tablero[TamTablero][TamTablero];
int i,j;
for(i = 0; i < TamTablero; i++)
for(j = 0; j < TamTablero; j++)
tablero[i][j] = '*';
srand (time(NULL));
int arboles = 0;
while(arboles < TamTablero + 3){
i = rand() % TamTablero;
j = rand() % TamTablero;
if( tablero[i][j] != 'X'){
tablero[i][j] = 'X';
arboles++;
}
}
printf("\n ");
for (j=0; j<TamTablero; j++)
printf(" %c", 'A' + j);
printf("\n");
for (i=0; i<TamTablero; i++){
printf("%d |", i+1);
for (j=0; j<TamTablero; j++){
printf(" %c", tablero[i][j]);
}
printf(" \n");
}
return 0;
} ```