Endil

Dorofeev-lab2

Feb 6th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. void close (ifstream &first, ifstream &second) {
  9.     first.close();
  10.     second.close();
  11.     system("del 1.txt");
  12.     system("del 2.txt");
  13. }
  14.  
  15. int main(int argc, char* argv[])
  16. {
  17.     if (argc < 3) {
  18.         cout << "No enough arguments" << endl;
  19.         return 0;
  20.     }
  21.     string com1 = argv[1];
  22.     com1 = "dir \"" + com1 + "\" /a:-d /b >>1.txt 2>nul";
  23.     string com2 = argv[2];
  24.     com2 = "dir \"" + com2 + "\" /a:-d /b >>2.txt 2>nul";
  25.     system(com1.c_str());
  26.     system(com2.c_str());
  27.     ifstream first("1.txt"), second("2.txt");
  28.     if (first.is_open() && second.is_open()) {
  29.         while (first.good()) {
  30.             string s1, s2;
  31.             getline(first, s1);
  32.             getline(second, s2);
  33.             if (s1 != s2) {
  34.                 cout << "Folders not equal" << endl;
  35.                 close(first, second);
  36.                 return 0;
  37.             }
  38.         }
  39.         if (second.good())
  40.             cout << "Folders not equal" << endl;
  41.         else
  42.             cout << "Folders are equal" << endl;
  43.         close(first, second);
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment