q. After adding fflush(stdin)
the a[0]
of string a have an character but when I remove it I can add one less chracter th that same string the a[0]
character is blank. i am not having this problem when using this for integer input array. i want to know the reason behind it not alternate option(like getchar)
#include <stdio.h>
int main()
{
char a[50], b;
int c, d, e, f;
printf("enter the size of the string");
scanf("%d", &c);
fflush(stdin);
printf("enter the string");
for (d = 0; d < c; d++)
{
scanf("%c",&a[d]);
}
for(d = 0; d < c; d++)
{
printf("%d %c\n",d,a[d]);
}
return 0;
}