Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
882B

  1. // Windows does not have unix diff so this is a simple replacement
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5. int main(int argc, char *argv[] ) {
  6. int rc=-1;
  7. if (argc != 3) {
  8. cout << "usage: " << argv[0] << " file1 file2\n";
  9. return -1;
  10. }
  11. char *file1 = argv[1];
  12. char *file2 = argv[2];
  13. ifstream is1(file1, ios::in);
  14. ifstream is2(file2, ios::in);
  15. if (is1.fail()) {cerr << "failed to open " << file1 << "\n"; goto done;}
  16. if (is2.fail()) {cerr << "failed to open " << file2 << "\n"; goto done;}
  17. char d1[256], d2[256];
  18. do {
  19. is1.read(d1,sizeof(d1));
  20. is2.read(d2,sizeof(d2));
  21. if ((is1.gcount() != is2.gcount()) || memcmp(d1,d2,is1.gcount())) {
  22. cout << file1 << " and " << file2 << " differ\n";
  23. goto done;
  24. }
  25. } while (!is1.eof() && !is2.eof());
  26. rc=0;
  27. done:
  28. is1.close();
  29. is2.close();
  30. return rc;
  31. }