program with structure!

I need to write a program that will serve as a program for the library. The structure will be called library, and it will include 4 variables - book name, catalog number, fiction or nonfiction, and auther. The program will also declare three objects of this structure called book1, book2 ,and book3.
Could someone help me with the structure part please, cuz i have no clue what to do :(
1
2
3
4
5
6
typedef struct {
  char title[60]; /* book title - 59 characters or less */
  double call_number; /* "catalog number" is like 005.21, right? */
  bool isFiction; /* determines whether a book is fiction or nonfiction */
  char author[59]; /* author's name - 58 characters or less */
} book;


I hope this helps! ^_^

rpgfan
One more question. I have to enter all the information and output it to the screen. How do i program the source code so i dont have to use all those cout and cin for all 3 objects?
you have to use cout and cin.
for example,if you want to accept the call_number information. You have to type :-

cin>>book.call_number;

Last edited on
Note that you only need to code for input of 1 book and put it in a function call - you can then call the function for book1, book2, book3.

EG
1
2
3
4
5
6
7
8
9
10
11
void enterBook(book & theBook)    //pass by reference
{
    //cin & cout to prompt user for book details and enter them
}
...

book book1,book2,book3;

enterBook(book1);
enterBook(book2);
enterBook(book3);
Topic archived. No new replies allowed.