我想要做的是提示用户输入文件以将数据保存在我尝试过的是:
string save;
cout<<"Enter filename to save (ex: file.txt): ";
cin>>save;
ofstream myfile;
myfile.open(save);
myfile <<"ID \tName \tSales\n";
但是我得到一个错误:没有匹配函数调用'std::basic_ofstream >::open(std::string&)'</p>
编辑:
所以我更新了我的代码,但这不允许我输入文件名。这是为什么
char file_name[81];
cout<<"Enter filename to save (ex: file.txt): ";
fflush(stdin);
cin.getline(file_name, 81);