C++ 从printf scanf转换为cin cout时出现的问题

C++ 从printf scanf转换为cin cout时出现的问题,c++,syntax,C++,Syntax,在我的家庭作业中,我被要求将我以前的项目从使用改为。在这个过程中,我犯了不少错误,只是有点被一些特定的错误卡住了 就我的预处理器指令而言,我包括: #include <iostream> #include <iomanip> #include <fstream> 此错误来自以下行: void PrintAverages(ofstream &output, int tot_employees, float tot_payrate, float tot_

在我的家庭作业中,我被要求将我以前的项目从使用
改为
。在这个过程中,我犯了不少错误,只是有点被一些特定的错误卡住了

就我的预处理器指令而言,我包括:

#include <iostream>
#include <iomanip>
#include <fstream>
此错误来自以下行:

void PrintAverages(ofstream &output, int tot_employees, float tot_payrate, float tot_reghrs,
                   float tot_ovthrs, float tot_gross, float tot_fed, float tot_state,
                   float tot_ssi, float tot_def, float tot_net)
{      

    output << reportfile, "\n\nAverages:" << tot_payrate / tot_employees <<
              tot_reghrs / tot_employees << tot_gross / tot_employees <<
              tot_fed / tot_employees << tot_ssi / tot_employees << tot_net / tot_employees <<
              tot_ovthrs / tot_employees << tot_state / tot_employees << tot_def / tot_employees;
}
void打印平均值(流量和产量、总员工数、浮动总工资率、浮动总工资率、,
浮动总存量、浮动总存量、浮动总存量、浮动总存量、浮动总存量状态、,
浮动总成ssi、浮动总成def、浮动总成净值)
{      

输出什么类型的
reportfile
reportfile
\n\n字符:
字符串之间的逗号看起来很奇怪-不应该是

as ofstream在命名空间std中声明


此外,reportfile后面的逗号应该是
不确定,但这可能会导致问题:
reportfile,“\n\n平均值:
这不是答案,但您可以简单地
包括
并使用
scanf()
而不是更改为
iostream
。我必须尝试并坚持使用cin/COUT提供的代码在所述问题中没有缺陷。您需要显示更多代码。此外,忽略
shg
,不要靠近C I/O函数。因此可能会出现以下情况:输出哦,我明白了。显然,报告文件没有必要。
void PrintAverages(ofstream &output, int tot_employees, float tot_payrate, float tot_reghrs,
                   float tot_ovthrs, float tot_gross, float tot_fed, float tot_state,
                   float tot_ssi, float tot_def, float tot_net)
{      

    output << reportfile, "\n\nAverages:" << tot_payrate / tot_employees <<
              tot_reghrs / tot_employees << tot_gross / tot_employees <<
              tot_fed / tot_employees << tot_ssi / tot_employees << tot_net / tot_employees <<
              tot_ovthrs / tot_employees << tot_state / tot_employees << tot_def / tot_employees;
}
std::ofstream