problem with my code
Find matching numbers in text files file1.txt and file2.txt and write them to a new text file result.txt. In each of the source files, the numbers are not repeated. the code i tried #include<iostream> #include<fstream> #include<iomanip> #include<numeric> #include<math.h> using namespace std; int main(){ int i, n1,n2; int tab1[20]{}; int tab2[20]{}; int compare = 0; fstream f1; f1.open("c:\\Temp\\file1.txt",ios::in); fstream f2; f2.open("c:\\Temp\\file2.txt",ios::in); fstream f3; f3.open("c:\\Temp\\result.txt",ios::out|ios::trunc); bool flag = false; if(f1 && f2 && f3){ while(!f1.eof()&& !f2.eof()){ f1>>n1; f2>>n2; cout<<endl<<n1<<" "<<n2<<" "; } bool arraysEgaux=false; do{ cin>>tab1[i]; for(int j = 0; j < n2; j++){ if(tab1[i]==tab2[j]){ arraysEgaux=true; break; cout<<tab1[i]<<" "; f3<<tab1[i]<<" "; i++; } } }while (i<20); } f1.close(); f2.close(); f3.close(); } cout<<"ERROR "<<endl; //system("pause"); //return 0;