I have notice that only first scanf from for loop is asked and rest of them skip scanf request.
int main()
{
int c = 0;
int i;
struct book
{
char name[20];
float price;
int page;
};
printf("\n enter number of book to add\n ");
scanf("%d", &c);
struct book b[c];
printf("\n book details \n ");
for (i = 1; i < c; i++)
{
printf("\n enter name for book %d", i);
scanf(" %c", &b[i].name);
fflush(stdin);
printf("\n enter price for book %d", i);
scanf(" %f", &b[i].price);
fflush(stdin);
printf("\n enter page for book %d", i);
scanf(" %d", &b[i].page);
}
}
OUTPUT
enter number of book to add 3
book details enter name for book 1james
enter price for book 1
enter page for book 1
enter name for book 2
enter price for book 2
enter page for book 2