【发布时间】:2016-04-27 20:20:57
【问题描述】:
我一直在尝试将其写入文件,但无济于事我找到了一种方法,我还需要能够从中读取。这是结构
struct details
{
float balance=0;
vector<string> history;
string pin;
};
struct customer
{
int vectorID;
string name;
char type;
details detail;
};
vector<customer> accounts;
我现在拥有的是:
ofstream fileBack;
fileBack.open("file.txt", ios::in|ios::binary|ios::trunc);
fileBack.write(reinterpret_cast<char*>(&accounts), accounts.size()*sizeof(accounts));
fileBack.close();
而且我知道这是错误的,因为当我打开文件时,它还不足以包含我放入其中的信息。 感谢所有帮助,提前感谢您
【问题讨论】:
-
你找到了错误的方式。
-
是的,我想,我只是在黑暗中拍摄,希望有什么东西能粘住
标签: c++ vector struct binaryfiles