我有一个文件需要在运行时多次打开。每次将一些文本添加到文件中。下面是代码:重复使用流迭代器
ofstream fs;
fs.open(debugfile, fstream::app);
ostream_iterator<double> output(fs, " ");
copy(starting_point.begin(), starting_point.end(), output);
...
fs.open(debugfile, fstream::app);
ostream_iterator<double> output1(fs, " ");
copy(starting_point.begin(), starting_point.end(), output1);
我的问题是,我可以用一个流迭代器“输出”每次我打开该文件时,如一些方法来清理它?
感谢
为什么不把可重用代码的函数和调用该函数多次? – NathanOliver
那是对的。我可以这样做。 – colddie