void book_author_search() { cout << "Enter the book's author:" << endl; string name; cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); getline(cin, name); Category *tmp1 = beginning; Book *tmp; vector <Book *> list; system("CLS"); cout << "Searching..." << endl; int i = 0; while (tmp1 != NULL) { tmp = tmp1->getHead(); while (tmp != NULL) { if (iequals(tmp->getAuthor(), name)) { list.push_back(tmp); i++; cout << "Result no." << i << endl; tmp->print(); } tmp = tmp->getNext(); } tmp1 = tmp1->getNext(); } if (i == 0) { system("CLS"); cout << "No such ID was found." << endl; cout << "Please try again" << endl; } else { cout << "Which of the results do you want to manage? (enter a number)" << endl; stahp(); int ch; cin >> ch; ch--; if (ch > 49 || list[ch] == NULL) { cout << "Invalid response. Please start again." << endl; } else book_menu(list[ch]); } }
//book searching functions void book_id_search() { cout << "Enter the book's ID:" << endl; int id; cin >> id; Category *tmp1 = beginning; Book *tmp; system("CLS"); cout << "Searching..." << endl; int i = 0; while (tmp1 != NULL) { tmp = tmp1->getHead(); while (tmp != NULL) { if (tmp->getID() == id) { i++; tmp->print(); book_menu(tmp); return; } tmp = tmp->getNext(); } tmp1 = tmp1->getNext(); } if (i == 0) { system("CLS"); cout << "No such ID was found." << endl; cout << "Please try again" << endl; } }