The first input is stored in arr [0] [0], and then when you press enter (return key), it is stored in arr [0] [1], and when you think that you enter the second character, you are actually give the third entrance. Try the code below to see if you received it.
#include<stdio.h> #include<stdlib.h> int main() { char arr[3][3]; int i,j,n; for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("Input array [%d][%d]",i,j); scanf("%c",&arr[i][j]); } } }
As for the correction, you need scanf(" %c",&arr[i][j]); space infront% c to use \n
I hope he answers your question.
source share