#include <iostream> #include <fstream> #include <map> using namespace std; struct book{ string type; string bookname; float money; int zt; string cbs; }Book; void MIAN(){ cout<<"欢迎使用图书管理系统"<<endl <<"***1.输出所有图书***"<<endl <<"***2.输出可借图书***"<<endl <<"***3.添加新的图书***"<<endl <<"***4.删除指定图书***"<<endl <<"***5.查找图书信息***"<<endl <<"***6.借阅指定图书***"<<endl <<"***7.归还指定图书***"<<endl <<"***8.关闭管理系统***"<<endl; } int main(){ map<string,book> a; int I,number = 10; ifstream file; file.open("1.txt"); string data; while(getline(file,data)){ Book.type = data.substr(0,data.find("|")); data = data.substr(data.find("|")+1); Book.bookname = data.substr(0,data.find("|")); data = data.substr(data.find("|")+1); Book.money = stof(data.substr(0,data.find("|"))); data = data.substr(data.find("|")+1); Book.cbs = data.substr(0,data.find("|")); a[Book.type] = Book; } while(1){ MIAN(); cin>>I; switch(I){ case 1:{ break; } case 8:{ cout<<"欢迎下次使用!"<<endl; return 0; } system("pause"); } } return 0; }
标签:string,管理系统,substr,Book,file,data,find,图书 From: https://www.cnblogs.com/wangyihang-xh/p/18076737