I want to change my enum code with related values and want to get same output like before change. But i am getting different output. Codes before change were showed in comment lines. How and why it can be? I give the values to get same output. I can't understand why didn't i get the same output? (Random number not a problem. After change, it is not printing the board, just printing first user value not continue, not getting an error just keeping to look like the ss)
//enum {_,X,O}
enum {X,O,_};
//int user = 1;
//int comp = 2;
int user = 0;
int comp = 1;
void initBoard(int board[]){
int n_pieces_user; //number of pieces for user
int n_pieces_comp; //number of pieces for computer
int n_pieces_sum;
int chosen_player;
int position;
printf("Input number of pieces for user and computer respectively: ");
scanf("%d %d", &n_pieces_user, &n_pieces_comp);
int n_pieces_sum = n_pieces_user + n_pieces_comp;
int arr_pos[n_pieces_sum];
printf("Press 1 to choose Player1, press 2 to Player2 (Player1 plays first!): ");
while(1){
scanf("%d",&chosen_player);
if(chosen_player == 1){ //User plays first
srand((unsigned)time(&t)); //initializes random number generator
for(i=0; i<n_pieces_sum; i++){
position = rand()%SIZE;
for(k=0; k<i; k++){
//while((board[position]==1) || (board[position]==2)){
while((board[position] == 0) || (board[position] == 1)){
position = rand()%SIZE;
arr_pos[i] = position;
}
arr_pos[i] = position;
}
if(i<n_pieces_user){
arr_pos[i] = position;
printf("\nUser's random initial piece position: %d", arr_pos[i]);
board[position] = 0;
}
if(i>=n_pieces_user && i<n_pieces_sum){
arr_pos[i] = position;
printf("\nComputer's random initial piece position: %d", arr_pos[i]);
board[position] = 1;
}
}
turn = comp;
break;
}
else if(chosen_player == 2){ //Computer plays first
srand((unsigned)time(&t)); //initializes random number generator
for(i=0; i<n_pieces_sum; i++){
position = rand()%SIZE;
for(k=0; k<i; k++){
//while((board[position]==1) || (board[position]==2)){
while((board[position]==0) || (board[position]==1)){
position = rand()%SIZE;
arr_pos[i] = position;
}
arr_pos[i] = position;
}
if(i<n_pieces_comp){
arr_pos[i] = position;
printf("\nComputer's random initial piece position: %d", arr_pos[i]);
board[position] = 0;
}
if(i>=n_pieces_comp && i<n_pieces_sum){
arr_pos[i] = position;
printf("\nUser's random initial piece position: %d", arr_pos[i]);
board[position] = 1;
}
}
turn = user;
break;
}else
printf("Choose correct input!\n");
}
printf("\n");
}
void printBoard(const int board[]){
char symbol[] = { 'X','O','_' };
//char symbol[] = { '_','X','O' };
printf("\n BOARD\n\n");
for(i=0; i<SIZE; i++) {
if(i != 0 && i%7 == 0)
printf("\n\n");
printf(" %c ",symbol[board[i]]);
}
printf("\n\n");
}