C++ 使用fstream将精度设置为输出文件格式双精度
对于如何使用已打开的fstream将格式化的double输出到文本文件,我找不到答案。目前,我的代码正在执行以下操作:C++ 使用fstream将精度设置为输出文件格式双精度,c++,double,precision,fstream,C++,Double,Precision,Fstream,对于如何使用已打开的fstream将格式化的double输出到文本文件,我找不到答案。目前,我的代码正在执行以下操作: int writeToFile (fstream& f, product_record& p) { if (!f){ cout << "out file failed!!error" << endl; return -1; } else { f << p.idnumber &l
int writeToFile (fstream& f, product_record& p)
{
if (!f){
cout << "out file failed!!error" << endl;
return -1;
} else {
f << p.idnumber << endl;
f << p.name << endl;
f << p.price << endl;
f << p.number << endl;
f << p.tax << endl;
f << p.sANDh << endl;
f << p.total << endl;
f << intArrToString( p.stations ) << endl;
}
}
int writeToFile(fstream&f、产品记录&p)
{
如果(!f){
不能尝试使用
#包括//std::setprecision()
f好的,我的坏消息我会在一秒钟内把它打印出来。f请在毫无理由地公然否决投票之前尝试提供建设性的批评。谢谢@user657267我会尝试。这解决了问题,非常感谢。我仍然有点困惑,为什么没有修复
它就不能工作。