Data transfer file1 to file2 by math formula (3%==0)
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int num1;
fstream file, doc1, doc2;
file.open("jon.txt", ios::out);
if (!file)
{
cout << "file does
not open";
}
else
{
cout << "file
open successfully " << endl;
}
doc1.open("game.txt", ios::in);
if (!doc1)
{
cout << "file
does not open";
}
else
{
cout << "file
open successfully " << endl;
}
doc2.open("play.txt", ios::out);
while (!doc1.eof())
{
doc1 >> num1;
if (num1 % 3 == 0)
{
file << num1 << "\t";
}
doc2 << num1 << "\t";
}
doc1.close();
file.close();
doc2.close();
cout << endl;
system("pause");
}
Comments
Post a Comment