标签:using fstream ace c_str als lag close namespace etl
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string x, y, z;
cin >> x >> y >> z;
ifstream file1(x.c_str());
ifstream file2(y.c_str());
ofstream file3(z.c_str());
string a, b;
getline(file1,a);
getline(file2,b);
int aa=a.length();
int bb=b.length();
cout<<"length of file1:"<<aa<<endl<<"length of file2:"<<bb<<endl;
if(aa>=bb){
aa=bb;
}
bool flag = true;
for(int i=0;i<aa;i++){
if(a[i]!=b[i]){
cout<<"file1:";
cout<<a<<endl;
cout<<"file2:";
cout<<b<<endl;
file3 << "Different " << i << endl;
cout << "Different " << i << endl;
flag = false;
break;
}
}
if(flag){
cout<<"file1:";
cout<<a<<endl;
cout<<"file2:";
cout<<b<<endl;
file3 << "Same " << aa << endl;
cout << "Same" << aa << endl;
}
file1.close();
file2.close();
file3.close();
}
标签:using fstream ace c_str als lag close namespace etl
原文地址:http://www.cnblogs.com/sysu-eeman-yang/p/5987515.html