I want to first user to tell me how many elements they want in the array. Then I create an array of char (char a[n]) where n is the number of elements I got from the user. I want to for loop to scan the input of character. But the for loop jumps two times and scan the input.
#include <stdio.h>
int main(void)
{
int n, i;
printf("How many elements you want in the array? ");
scanf("%d",&n);
char a[n];
for(i = 0; i < n; i++)
{
printf("Enter a character: ");
scanf("%c", &a[i]);
}
for(i = 0; i < n; i++)
{
printf("%c", a[i]);
}
return 0;
}