Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- void close (ifstream &first, ifstream &second) {
- first.close();
- second.close();
- system("del 1.txt");
- system("del 2.txt");
- }
- int main(int argc, char* argv[])
- {
- if (argc < 3) {
- cout << "No enough arguments" << endl;
- return 0;
- }
- string com1 = argv[1];
- com1 = "dir \"" + com1 + "\" /a:-d /b >>1.txt 2>nul";
- string com2 = argv[2];
- com2 = "dir \"" + com2 + "\" /a:-d /b >>2.txt 2>nul";
- system(com1.c_str());
- system(com2.c_str());
- ifstream first("1.txt"), second("2.txt");
- if (first.is_open() && second.is_open()) {
- while (first.good()) {
- string s1, s2;
- getline(first, s1);
- getline(second, s2);
- if (s1 != s2) {
- cout << "Folders not equal" << endl;
- close(first, second);
- return 0;
- }
- }
- if (second.good())
- cout << "Folders not equal" << endl;
- else
- cout << "Folders are equal" << endl;
- close(first, second);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment