Guest User

Untitled

a guest
May 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. // Textcomparer crated by Emil "BubbleQ" Dahlqvist and with lot of help from Chris, a danish guy.
  2. #include<iostream>
  3. #include<fstream>
  4. #include<string>
  5. #include<windows.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. //Vilka strängar som skall få vara med och vilka två som skall höra ihop med varandara :)
  12. string a_crackbone;
  13. string b_crackbone;
  14. string a_textname;
  15. string b_textname;
  16. ifstream fsFileIn;
  17. ifstream fsFileInTwo;
  18.  
  19. // Beatiful colors <3
  20. HANDLE rainbow = GetStdHandle(STD_OUTPUT_HANDLE);
  21.  
  22. //Get filename and make it into one of my strings
  23. SetConsoleTextAttribute(rainbow,15);
  24. cout << "Enter the first text or cfg file here, with .txt ending!: ";
  25. getline(cin,a_textname);
  26.  
  27.  
  28. // Gonna fix so that you don´t have to relaunch the program every time you hit wrong filename
  29. fsFileIn.open(a_textname.c_str());
  30.  
  31. if(!fsFileIn.is_open())
  32. {
  33. cout << "Error: Couldn't open file: " << a_textname << endl;
  34. cin.get();
  35. return 0;
  36. }
  37. else
  38. {
  39.  
  40.  
  41. cout << "Reading from file: " << a_textname << endl;
  42.  
  43. //Read file and print to console
  44. while(!fsFileIn.eof())
  45. {
  46. getline(fsFileIn,a_crackbone);
  47. SetConsoleTextAttribute(rainbow,3);
  48. cout << a_crackbone << endl;
  49. }
  50. SetConsoleTextAttribute(rainbow,15);
  51. cout << "Succesfully loaded file nr 1, now press ENTER to confirm." << endl;
  52. }
  53.  
  54. cin.get();
  55.  
  56. // *************GET THE OTHER TEXT!****************************************************************************************************
  57.  
  58. //Get filename and make it into one of my strings
  59. cout << "Great! Now enter the second text/cfg file here, also with the .txt ending!: ";
  60. getline(cin,b_textname);
  61.  
  62.  
  63. // Gonna fix so that you don´t have to relaunch the program every time you hit wrong filename
  64. fsFileInTwo.open(b_textname.c_str());
  65.  
  66. if(!fsFileInTwo.is_open())
  67. {
  68. cout << "Error: Couldn't open the second file: " << b_textname << endl;
  69. cin.get();
  70. return 0;
  71. }
  72. else
  73. {
  74.  
  75.  
  76. cout << "Reading from file: " << b_textname << endl;
  77.  
  78. //Read file and print to console
  79. while(!fsFileInTwo.eof())
  80. {
  81. getline(fsFileInTwo,b_crackbone);
  82. SetConsoleTextAttribute(rainbow,3);
  83. cout << b_crackbone << endl;
  84. }
  85. SetConsoleTextAttribute(rainbow,15);
  86. cout << "Succesfully loaded file nr 2, press enter to start the comparsion!" << endl;
  87. }
  88.  
  89. cin.get();
  90.  
  91. // Now will shall compare them!!!!!!!!! Wohoo! After the guy has presed enter!
  92.  
  93. if( a_crackbone == b_crackbone )
  94. {
  95. SetConsoleTextAttribute(rainbow,2);
  96. cout << "Both files matches perfectly, lucky for you!" << endl;
  97. }
  98.  
  99. else
  100. {
  101. SetConsoleTextAttribute(rainbow,4);
  102. cout << "The files does not match eachother, too bad." << endl;
  103. }
  104.  
  105. SetConsoleTextAttribute(rainbow,2);
  106. return 0;
  107. }
Add Comment
Please, Sign In to add comment