#include <iostream> #include <map> #include <fstream> #include <iostream> #include <bits/c++config.h> using namespace std; struct book{ string book_name; string money; string cbs; string name; }; int main(){ string str; map<string,book> a; book shu; shu.book_name="语文"; shu.cbs="人民大学出版社"; shu.money=50.3; shu.name="哈哈哈哈哈"; a.insert(pair<string,book>("语文",shu)); string d; ifstream b; b.open("新建文本文档.txt"); b>>d; cout<<d<<endl; b.close(); int i=0; while(getline(b,d)){ i++; } int j=0; while(i<j){ for(j=0;j<i;j++){ shu.name=d.substr(0,d.find("|")); cout<<shu.name<<endl; d=d.substr(d.find("|")+1); shu.cbs=d.substr(0,d.find("|")); cout<<shu.cbs<<endl; d=d.substr(d.find("|")+1); shu.money=d.substr(0,d.find("|")); cout<<shu.money<<endl; d=d.substr(d.find("|")+1); shu.name=d.substr(0,d.find("|")); cout<<shu.name<<endl; } } ofstream f; return 0; }
标签:shu,管理系统,money,name,book,include,图书,string From: https://www.cnblogs.com/boyeyuan/p/18076757