Can anybody tell me why the loop does not exit whenever I press letter X? How to make the program not get the value of backspace and enter into the array?
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define N 2
#define M 4
int main()
{
int i,j,a[N][M];
for(i=0;i<N;i++)
{
for(j=0;j<M;j++)
{
scanf("%c",&a[i][j]);
if(a[i][j]=='X')
break;
}
if(a[i][j]=='X')
break;
}
return 0;
}