输入输出流采用引用调用可以事先不用传文件名
#include<fstream>
using namespace std;
void print_row(ofstream& out, char c, int n);
int main()
{
ofstream outfile;
outfile.open("out2.txt");
print_row(outfile, 'c', 10);
outfile.close();
return 0;
}
void print_row(ofstream& out, char c, int n)
{
for(int i=0;i<n;i++)
out<<c<<endl;
}