gpt4 book ai didi

c++ - 写在文件上,信息最终出现在控制台中

转载 作者:行者123 更新时间:2023-11-30 04:54:40 24 4
gpt4 key购买 nike

<分区>

这是一个项目,我需要在其中列出用户将输入的项目,并且需要将它们写入文件中。但是它会为其中的每个条目打印 @4761920nan。然后它将所有应该在控制台上的文件中打印出来。任何有关此问题的信息都将不胜感激。

int main()
{
ofstream data("list.txt");
int n;
cout << "How many cabins are in your region? "; cin >> n; cout<<endl;
cabin*tour=
new cabin[n];

for (int i=0; i<n; i++)
{
tour[i].nameInput();
data<<tour[i].nameOutput();
tour[i].capacity();
data<<tour[i].capacityOutput();
tour[i].gps();
data<<tour[i].gpsOutput();
};

data.close();
return 0;
}

这是 nameOutput() 的样子:

char cabin::nameOutput()
{
cout<<"Name: "<< name<<endl;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com