Question: #include #include #include #include using namespace std; int main() { map mp; map ::iterator it, it1; int choice; string author, title; while (1) { cout

#include #include #include #include using namespace std;

int main() { map mp; map::iterator it, it1; int choice; string author, title; while (1) { cout<<" ---------------------"<>choice; switch(choice) { case 1: getchar(); cout<<"Enter Author Name to be inserted: "; getline(cin, author); cout<<"Enter Book Title to be inserted: "; getline(cin, title); mp.insert (pair(author, title)); break; case 2: getchar(); cout<<"Enter Author Name to be deleted: "; getline(cin, author); it=mp.find(author); if (it != mp.end()) { cout<<"Element found and deleted"<

break; case 5: cout<<"Size of the Map: "< "<<(*it).second<

When I input choice with some letters such as "p" "af" ...like that, this program will be endless loop. How can I fix it?

Thank you1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!