Question
=You ar quite an avid reader and would like to write a program that manages your collection of books. In particular, you want the following
=You ar quite an avid reader and would like to write a program that manages your collection of books. In particular, you want the following functionality:
1) Search for a book from the collection a) If the book is not found your program should return an appropriate message b) otherwise, this function returns the number of copies of the book in the collection
2) List all of the books by a particular author from the collection Your program will create the library as an array of structs, from entries for each book read from an input file called library.txt. Your library will never exceed 100 books. Input Specification (for library.txt) The first line of the file will contain a single positive integer representing the number of books in the library. (Note: We assume that at the beginning of the program, the library is empty.) Each following line will have data for a single book in the library.
Book data is provided in the following format: TITLE AUTHOR_fname AUTHOR_lname Number_of_copies The title, author_firstname and author_lastname will be strings that contain alphabetic letters and underscores. None of these strings will exceed 39 characters. The title will be unique to the collection. The library may contain multiple books by the same author, and multiple copies of the same book, but no two book entries (book structs in your program) will ever have the same title. You may assume that the Number_of_copies will indicate how many copies of that book are in the library.
Output Specification
All output should go to the screen. Separate the output for each processed request with one blank line. 2 For searching for a book, output one of two statements, depending on whether or not the designated book was found in the library: There are n copies of book X currently in the library. The book X is NOT currently in the library. For the book to be found, the title must match exactly, including capitalization. For searching for all the books by a particular author, output a single line of the form: List of all books by X X represents the author requested. Each following line should list the title of one book by that author in the library. List each book exactly once. Implementation Restrictions You must use the following constants: #define MAX_LENGTH 40 #define MAX_BOOKS 100 You must use the following struct to store information about one book: struct book { char title[MAX_LENGTH]; char authorfname[MAX_LENGTH]; char authorlname[MAX_LENGTH]; int numcopies; }; When run, your program will: 1. Create the library 2. Prompt the user to select one of 2 choices: a. title of a book to search for b. an author name to search for 3. Your program should then process the users selected choice. (it is up to you to plan how you will implement this part) 4. Your program should repeat steps 2-3 until the user is done. Hint: Remember to use strcpy whenever you want to copy the contents of one string into another, instead of the equals sign. Whenever you list all of the books by a particular author, list them in the order in which they appear in the library, by index into the array in the struct library.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started