I\'m learning about data structures. I\'ve written a simple program that asks the user to fill in information on a 3 book purchase. Like name of book, author, cost and pages.
Change like this
for(ctr = 0; ctr < 3; ctr++)
{
printf("What is the name of the book #%d?\n", (ctr+1));
gets(books[ctr].title);
puts("Who is the author? ");
gets(books[ctr].author);
puts("How much did the book cost? ");
scanf("%lf$", &books[ctr].price); //Changed
puts("How many pages in the book? ");
scanf(" %d", &books[ctr].pages);
getchar(); // Clears last newline for the next loop
}
scanf man page