struct book{ char name; float price; int pages;};struct book b[4];int i;for(i=0;i<4;i++){ printf("Enter name, price and pages in the book:\n"); scanf("%c %f %d", &b[i].name, &b[i].price, &b[i].pages);}
when I run the above code, it asks for all three variables only in first iteration and for the next iteration onwards I can only enter first value(i.e. char). I know there is something wrong with the float variable here since I am getting random huge values when trying to display it. How do I solve it and what actually is going on?
I using gcc on linux.
A detailed explanation is appreciated. Thank you.