-
I think this is what you may be trying to get at...
Code:
int main()
{
ifstream infile("test.txt");
ofstream outfile("output.txt");
ostream_iterator<DString> outIter(outfile, "\n");
istream_iterator<DString> inIter(infile);
istream_iterator<DString> endIter;
copy(inIter, endIter, outIter);
return 0;
}
This will copy the contents of test.txt to output.txt.
Please note the use of "DString" - my own derived string class.
This code does not work correctly with the string class provided with VC++6.0 sp5.
Hope this gives you the general idea.
-
Iam working with files on Binary mode.Will these iterators work for Binary mode as well apart from Text mode.
-
I have only worked with these iterators on text files, but they should work on binary.
Replace DString with char and add ios::binary and see what happens.