#include<iostream> #include<stdio.h> #include<cstring> #include<string> using namespace std; void printBook(struct Books book); void printBorrower(struct borrower borrow); struct Books { char title[50]; char author[50]; char subject[50]; int book_id; }; struct borrower { char name[50]; char course[50]; int year; int id; }; int main() { Books b1; borrower person; char opt; do { cout<<"Enter opt: "; cin>>opt; if(opt=='A') { cout<<"Enter Book title: "; cin.getline(b1.title,50); cout << "Enter Book author: "; cin.getline(b1.author,50); cout << "Enter Book subject: "; cin.getline(b1.subject,50); cout << "Enter Book ID: "; cin >> b1.book_id; } else if(opt=='B') { cout<<"Enter the borrower's name: "; cin.getline(person.name, 50); cout<<"Enter the borrower's course: "; cin.getline(person.course, 50); cout<<"Enter the borrower's year level: "; cin>>person.year; cout<<"Enter the borrower's ID : "; cin>>person.id; } else { printBook(b1); //Print Borrower printBorrower(person); } }while(opt!='Y'); system("pause"); } void printBook(struct Books book) { cout<<"Book title: "<<book.title<<endl; cout<<"Book author: "<<book.author<<endl; cout<<"Book subject: "<<book.subject<<endl; cout<<"Book ID : "<<book.book_id<<endl; } void printBorrower(struct borrower borrow) { cout<<"Borrower's name: "<<borrow.name<<endl; cout<<"Borrower's course: "<<borrow.course<<endl; cout<<"Borrower's year: "<<borrow.year<<endl; cout<<"Borrower's ID : "<<borrow.id<<endl; }
cin>>
cin.getline()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)