关于文件写不进去的问题
//-------------------------------入库操作---------------------------------------
goods leftgood; //全局变量
vector<goods> good;
struct goods
{
number1 number; //货品编号
char name[10]; //货品名称
Date outputD; //出售日期
float monOfsel; //出售单价
char nameOfsel[10]; //售货员姓名
Date inputD; //进货日期
float monOfbuy; //进货单价
char nameOfbuy[10]; //进货员姓名
};
void enlistGoods()
{
int choose;
initialization(); //初始化部分属性
good.clear();
while(1)
{
putGoods();
good.push_back(leftgood);
cout<<"继续商品入库登记输入1,不继续则输入0"<<endl;
cin>>choose;
if(choose==1)
continue;
else
break;
}
//A
{
openInputgood1(); //打开文件不清空
iofile.write((char *)&good[0],sizeof(goods)*good.size());
iofile.clear();
iofile.close();
}
//B
{
openGooddata1(); //打开不清空
iofile.write((char *)&good[0],sizeof(goods)*good.size());
iofile.clear();
iofile.close();
}
}
//------------------------------入库操作结束------------------------------------
我的问题是这样的,我调试过,只能写入B中的文件,无法写入A中的文件,但A语句中都执行了,调换AB位置,就只能写入A中的文件,无法写入A中的文件了。请高手帮忙