1使用boost::filesystem::fstream
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
struct history{
history(){}
~history(){}
uint32_t m_id;
uint32_t m_kk;
uint32_t m_sec;
std::string name;
friend fstream& operator >> (fstream & f, history &h){
char c;
f >> h.m_id;
f >> c;
f >> h.m_kk;
f >> c;
f >> h.m_sec;
f >> c;
f >> h.name;
f >> c;
}
friend fstream& operator << (fstream & f, const history &h){
f << h.m_id;
f << ",";
f << h.m_kk;
f << ",";
f << h.m_sec;
f << ",";
f << h.name;
f << "\n";
}
};
int main() {
std::string path = "wwww1.txt";
history