There were several syntax errors.
Code:
#include "bookinfo.h"
#include <stdio.h>
int main(void) {
struct bookInfo books[3];
for (int i = 0; i < 3; i++)
{
printf("What is the name of the book #%d?\n\n", (i+1));
gets (books[i] .title);
puts("Who is the author?");
gets(books[i].author);
puts("How much did the book cost?");
scanf(" $%f", &books[i].price);
puts("How many pages in the book?");
scanf(" %d", &books[i].pages);
getchar();
}
printf("\n\nHere is the collection of books: \n\n");
for (int i = 0; i < 3; i++)
{
printf("#%d: %s by %s",
(i+1), books[i].title, books[i].author);
printf("\n\nIt is %d pages and costs $.2f",
books[i].pages, books[i].price);
printf("\n\n");
}
return (0);
}
book.h
Code:
struct bookInfo {
char title [40];
char author [25];
float price;
int pages;
};