Guest User

Untitled

a guest
Nov 20th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. void difffiles(ifstream& fs1, ifstream& fs2){
  2. string line1;
  3. string line2;
  4. int len = file_lenght(fs1);
  5.  
  6. int* diff_chars = new int[len];
  7. while(getline(fs1, line1)){
  8. if(getline(fs2, line2)){
  9. cout << "executed 0;";
  10. global_remember = 0;
  11. size_t length1 = line1.length();
  12. size_t length2 = line2.length();
  13. for(int i = 0; i < length1 && i < length2; i++){
  14. if(line1[i] != line2[i]){
  15. diff_chars[global_remember++] = i;
  16. continue;
  17. }
  18.  
  19. }
  20. print_line(diff_chars, line1, line2, length1, length2);
  21. }
  22. }
  23. delete[] diff_chars;
  24. }
  25.  
  26. void openfiles(char* file1, char* file2){
  27. ifstream fs1(file1);
  28. ifstream fs2(file2);
  29. if(fs1.is_open() && fs2.is_open()){
  30. difffiles(fs1, fs2);
  31. } else{
  32. cout << "File doesn't exist" << '\n';
  33. exit(1);
  34. }
  35. }
  36.  
  37. int main(int argc, char* argv[]){
  38. if(argc <= 1){
  39. help(*argv);
  40. exit(1);
  41. } else if(argc == 4 || argc == 2){
  42. while(*argv++ != NULL && **argv == '-'){
  43. switch(*++*argv){
  44. case 'h':
  45. help(*--argv);
  46. return 0;
  47. break;
  48. case 'f':
  49. openfiles(*argv, *++argv);
  50. break;
  51.  
  52. }
  53. }
  54. }
  55. exit(0);
  56.  
  57. }
Add Comment
Please, Sign In to add comment