I want to take character input using scanf instead of getchar(). So I wrote this coder but each time I input one character value it iterates twice. So I am able to take only 5 inputs. Why is this happening?
#include<stdio.h>
int main() {
char arr[10];
for (int i = 0; i < 10; i++) {
printf("%d:", i);
scanf("%c", & arr[i]);
printf("%c", arr[i]);
printf("\n");
}
}