您的位置:首页 > 编程语言 > C语言/C++

C++ 输入输出流的引用调用

2014-02-26 16:58 190 查看
输入输出流采用引用调用可以事先不用传文件名

#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: