Code:
scanf("%c %f %d", &b[i].name, &b[i].price, &b[i].pages");
The problem is in red, above. Scanf() leaves a newline char behind in the input stream, always. That is no problem for numbers, because numbers are bigger, so scanf() just goes on past the little char of the newline.
But then you have the second time through the loop, and scanf() reaches the newline left behind from the last pages entry, and says "OK, you wanted a char. I got a char!", and accepts the newline char, as the b[1].name.
Now things go to hell in a handbasket, since you're entering a letter for name, and now scanf() is already looking for a price. So you're now trying to feed scanf() a newline, and a char, for a price, and it's just not computing.
So do it like this:
Code:
for(i=0;i<2;i++)
{
printf("\nEnter name, price and pages");
scanf("%c %f %d", &b[i].name, &b[i].price, &b[i].pages");
getchar(); //pull off the newline char
}
This is the most common noob problem, with C, imo.
Holy Cow, I've been ninja-posted!!