Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <cctype>
- #include "invmenu.h"
- #include "globals.h"
- #include "bookinfo.h"
- using namespace std;
- void setTitle();
- void showTitle();
- int findEmptySlot(); // function prototypes
- BookData Collection[20];
- void structtest()
- {
- const int SIZE = 80;
- char buffer[SIZE];
- int choice;
- do
- {
- cout << " Serendipity Bookssellsers " << endl;
- cout << " Inventory Database " << endl;
- cout << " " << endl;
- cout << " 1. Set Title " << endl;
- cout << " 2. Show Title " << endl;
- cout << " Enter Your Choice: ";
- cin.getline(buffer,SIZE);
- choice = atoi(buffer);
- switch(choice)
- {
- case 1:
- setTitle();
- break;
- case 2:
- showTitle();
- break;
- case 3:
- cout << "Returning to Main Menu!" << endl;
- break;
- default:
- cout << "Please enter a number in the range 1-5." << endl;
- }
- }while(choice != 3);
- }
- int findEmptySlot()
- {
- int index = -1;
- for(int i = 0; i < NUM_BOOKS; i++)
- {
- if(Collection[20].bookTitle == '\0')
- {
- index = i;
- break;
- }
- }
- return 1;
- }
- void setTitle()
- {
- const int BUFFER_SIZE = 80;
- char buffer[BUFFER_SIZE];
- int index = findEmptySlot();
- if(index != -1)
- {
- cout << "Enter the following Information to add a book" << endl;
- cout << "Book title : ";
- cin.getline(Collection[index].bookTitle, BUFFER_SIZE);
- }
- }
- void showTitle()
- {
- cout << Collection[20].bookTitle;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement