从void函数对offile的流引用 [英] ofstream refference to an outfile from a void function

查看:72
本文介绍了从void函数对offile的流引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我在这里做错了什么。我正在尝试通过void函数对ofstream进行引用并写入我的outfile 

Hi, I want to know what I'm doing wrong here. I'm trying to make a reference to the ofstream and write to my outfile through a void function 

void border(ofstream& outfile2);



int main()

{

ofstream outfile2;
	ifstream infile;
	infile.open("prog4.txt"); //opens the data fike
	outfile2.open("outfile.txt");

border(a)

}

void border(fstream& outfile2) {
	outfile << "@@@@@@ test @@@@@@\n";
	return;
}




我没有得到任何我的outfile上的输出

Im not getting any output on my outfile

推荐答案

在11/20/2016 10:57 PM,bluezapfusion写道:

On 11/20/2016 10:57 PM, bluezapfusion wrote:


[code]

void border(ofstream& outfile2);

[code]
void border(ofstream& outfile2);

int main ()$
{

int main()
{

ofstream outfile2;

  ifstream infile;

  infile.open(QUOT; prog4.txt"); //打开数据fike

  outfile2.open(" outfile.txt");

ofstream outfile2;
  ifstream infile;
  infile.open("prog4.txt"); //opens the data fike
  outfile2.open("outfile.txt");

border(a)

什么是"a",以及如何与infile或outfile2相关?

What's "a", and how, if at all, is it related to infile or outfile2?

此外,这一行缺少分号。

Also, this line is missing a semicolon.


void border(fstream& outfile2){

  outfile<< " @@@@@@ test @@@@@@ \ n";

void border(fstream& outfile2) {
  outfile << "@@@@@@ test @@@@@@\n";

什么是outfile,以及如果有的话它与outfile2有关吗?

What's outfile, and how, if at all, is it related to outfile2?


这篇关于从void函数对offile的流引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆