Advertisement
AlexandruFilipescu

C++ program that sees if the content of n files in a .txt is the same.

Aug 5th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main() {
  8.     int n,i;
  9.     cout << "Dati n fisiere: " << endl;
  10.     cin >> n;
  11.     ifstream f;
  12.     ofstream g("fisier_copie.txt");
  13.    
  14.     char FileName[20], linie[250], linie2[250];
  15.  
  16.     cout << "Nume: ";
  17.     cin >> FileName;
  18.     f.open(FileName);
  19.     while (!f.eof()) {
  20.         f.getline(linie, 250);
  21.         g << linie << endl;
  22.     }
  23.     f.close();
  24.    
  25.     for(i=1;i<n;i++){
  26.         ifstream g2("fisier_copie.txt");
  27.         cin >> FileName;
  28.         f.open(FileName);
  29.         while (!f.eof()) {
  30.             f.getline(linie, 250);
  31.             g2.getline(linie2, 250);
  32.             if (strcmp(linie, linie2)==0) {
  33.                 cout << "sunt egale";
  34.                 cout << endl;
  35.             } else {
  36.                 cout << "nu sunt egale";
  37.                 cout << endl;
  38.             }
  39.         }
  40.         f.close();
  41.         g.close();
  42.     };
  43.  
  44.  
  45.     system("pause");
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement