Advertisement
kraxor

What is the output and why?

Nov 4th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     const char constant[] = "This is constant data so it can not be changed.";
  7.     char hax[] = {0x2a, 0x48, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x2a};
  8.  
  9.     for (int i = 0; i < 100; ++i) {
  10.         int j;
  11.         for (j = 0; j < 49; ++j) if (hax[i + j] != constant[j]) break;
  12.         if (j == 49) {
  13.             cout << "offset = " << i << endl;
  14.             for (int k = 0; k < 8; ++k) hax[k + i + 8] = hax[k];
  15.         }
  16.     }
  17.  
  18.     cout << constant << endl;
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement