I've got a very simple code here:
char A[9];
for (int i = 0; i < 9; i++){
scanf("%c\n", &A[i]);
}
for (int i = 0; i < 9; i++){
printf("%c ", A[i]);
if (i == 2 || i == 5 || i == 8){
printf("\n");
}
}
It is supposed to create a 1x9 array, then read 9 letters from a user (letter, enter, letter, enter and so on) and put them into an array. Then it should print out the array as if it was 3x3 array. It works as it should with one weird exception: the first loop takes 10 letters from the user, not 9, why?
I found some information that it might be caused by the "\n" next to the "%c" in the loop, but when I delete it and leave just "%c" the program reads only 5 letters cause it takes enter as another char.
I also tried using "%s\n" instead, but then the stack around A is corrupted for some reason and it still reads 10 letters instead of 9.