此功能仅将其中一种葡萄酒输出到txt文件

时间:2019-07-18 12:48:58

标签: c++

我有一个循环,要求无限次输入数据,但问题是txt文件仅存储输入数据之一 如果需要更多代码,请添加注释,只是我是C ++新手

void printwine(Wine1 wine) { //data the user typed as output
    ofstream file_;
    file_.open("wine.txt");
    file_ << "Wine" << endl;
    file_ << "the name is: " << wine.name << endl;
    file_ << "it's year is: " << wine.year << endl;;
    file_ << "its country of creation is: " << wine.place << endl;;
    file_ << "it's price is: " << wine.price << endl;
    file_.close();
}

0 个答案:

没有答案