我正在编写一个图书程序,使用户能够向图书馆添加和查找图书。现在,我需要弄清楚如何使用 conio.h/任何其他替代方法接收用户的键盘输入。因此,如果用户按下“1”,则调用 AddMenu(),但如果他/她按下 2,则调用 FindMenu()。这是代码:
#include <iostream>
#include <conio.h>
using namespace std;
class Book {
public:
string title; //title of da book
double sepnum; //unique identification code (ex. 1111, 0009, etc.)
};
void AddMenu() {
Book book1;
cout << "********ADD MENU********" << endl;
cout << endl;
cout << endl;
cout << "Enter Book Name:" << endl;
cin >> book1.title;
cout << "Enter Book Callsign (Ex: 0001, 5672):" << endl;
cin >> book1.sepnum;
cout << "Succesfully added" << endl;
cout << endl;
cout << "************************" << endl;
}
void FindMenu() {
}
int main()
{
cout << "**********MENU**********" << endl;
cout << endl;
cout << endl;
cout << "1. Add Book" << endl;
cout << "2. Find Book" << endl;
cout << endl;
cout << "************************" << endl;
return 0;
}