1 #include <iostream> 2 #include <fstream> 3 using namespace std; 4 int main() 5 { 6 string x, y, z; 7 cin >> x >> y >> z; 8 9 ifstream file1(x.c_str()); 10 ifstream file2(y.c_str()); 11 ofstream file3(z.c_str()); 12 13 string a, b; 14 getline(file1,a); 15 getline(file2,b); 16 int aa=a.length(); 17 int bb=b.length(); 18 cout<<"length of file1:"<<aa<<endl<<"length of file2:"<<bb<<endl; 19 if(aa>=bb){ 20 aa=bb; 21 } 22 bool flag = true; 23 for(int i=0;i<aa;i++){ 24 if(a[i]!=b[i]){ 25 cout<<"file1:"; 26 cout<<a<<endl; 27 cout<<"file2:"; 28 cout<<b<<endl; 29 file3 << "Different " << i << endl; 30 cout << "Different " << i << endl; 31 flag = false; 32 break; 33 } 34 } 35 if(flag){ 36 cout<<"file1:"; 37 cout<<a<<endl; 38 cout<<"file2:"; 39 cout<<b<<endl; 40 file3 << "Same " << aa << endl; 41 cout << "Same" << aa << endl; 42 } 43 44 file1.close(); 45 file2.close(); 46 file3.close(); 47 }