#include "user.h"
#include <string>
using namespace std;
user::user(string aaa)
{
name=aaa;
log.open(name.c_str(), ios::in|ios::out | ios::trunc);
log<<flush;
}
void user::insert(string to, string message)
{
log.write("hallo",5);
}
void user::list(){
string mylist;
// getline("nicht hallo",list);
getline(log,mylist);
cout<<mylist;
}
user::~user()
{
log.close();//dtor
}
答案 0 :(得分:1)
在阅读
之前,必须将文件指针设置为开头log.seekg(0, std::ios::beg);