#include <stdio.h>
int main (void){
char board[3][3];
printf("Enter X or O>");
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
scanf("%c", &board[i][j]);
}
}
printf("Board: ");
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
printf(" %c", board[i][j]);
}
printf("\n");
}
}
/*Expected output:
X O X
O X O
X O O
Actual output:
Board: X
O
X
O
O
*/
I'm trying to make a 3x3 tic tac toe board using 2D arrays in C. This code works fine for an Int array but doesn't work as expected using char. I only get to input 5 characters for some reason instead of the 3x3=9 and the output is also jumbled. How can I fix this?