0

please help me to make this code it's the second one i post it here

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. #include<iostream> #include<fstream> #include<iomanip> #include<numeric> #include<math.h> using namespace std; int main(){ int n1,n2; int i=0; int j=0; char tab1[20]{}; char tab2[20]{}; 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); if(f1 && f2 && f3){ while(!f1.eof()&& !f2.eof()){ f1>>n1; f2>>n2; cout << n1 << " "<< n2<< endl; do{ for(i=0;i<n1;i++){ cin>>tab1[i]; for(j=0;j<n2;j++){ if(tab1[i]==tab2[j]) cout<<tab1[i]; f3 << tab1[i] << endl; i++; } } } while(i<n1); } f1.close(); f2.close(); f3.close(); } else{ cout<<"ERROR "<<endl; } system("pause"); return 0; }

9th Apr 2022, 10:52 AM
ARONA
ARONA - avatar
5 Réponses
+ 1
How see the input, I mean the text files? How should be the output text file? Do work your code, respectively what do not work and what is your question? Where you need a help?
9th Apr 2022, 11:12 AM
JaScript
JaScript - avatar
+ 1
Just run it in sololearn if possible and share a link
9th Apr 2022, 12:49 PM
Faisal Issaka
Faisal Issaka - avatar
0
Can you add to sololearn and share the link rather?
9th Apr 2022, 11:12 AM
Faisal Issaka
Faisal Issaka - avatar
0
by the way f3 is empty could you try this code in vs?
9th Apr 2022, 12:47 PM
ARONA
ARONA - avatar
0
Issaka i don't understand your question
9th Apr 2022, 12:48 PM
ARONA
ARONA - avatar