Home > Back-end >  C file stream iterators, speaking, reading and writing
C file stream iterators, speaking, reading and writing

Time:12-20

Problem: the function is called file2 file cannot be written to, write normal file3, solving

 

# include & lt; Iostream>
# include & lt; Iterator>
# include & lt; Algorithm>
# include & lt; Vector>
# include & lt; String>
# include & lt; Fstream>

using namespace std;

Bool fileFun (const string & amp; File1, const string & amp; File2, const string & amp; File3)
{
Ifstream fin1 (file1);
Ofstream fout2 (file2, fstream: : app);
Ofstream fout3 (file3, fstream: : app);
if(! Fin1 |! Fout2 |! Fout3) return false.

Istream_iterator & lt; Int> (fin1), in the end;
Ostream_iterator & lt; Int> Out2 (fout2, "");
Ostream_iterator & lt; Int> Out3 (fout3, "\ n");

While (in!=end)
{
If ((*) in % 2)
Out2=* in++;
The else
Out3=* in++;
}
Fin1. Close ();
Fout2. Close ();
Fout3. Close ();
return true;
}

Int main ()
{
Const string file1 (" data. TXT "), file2 (" dest1. TXT "), file3 (" dest2. TXT ");
if(! FileFun (file1, file2, and file3))
{
Cout & lt; <"Error" & lt; }
}

CodePudding user response:

, is this dest1. TXT it came the name of the problem, why not? The name

CodePudding user response:

The latest code file is normal, normal just vscode can't open the file, the data is written in

CodePudding user response:

Problem solving the grams