Advertisement
attilan

Pointers

Apr 16th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. void unknown(int* p, int num) {
  4.     int *q = &num;
  5.     *p = *q + 2;
  6.     num = 7;
  7. }
  8.  
  9. void hardToFollow(int* p, int q, int *num) {
  10.     *p = q + *num;
  11.     *num = q;
  12.     num = p;
  13.     p = &q;
  14.     unknown(num, *p);
  15. }
  16.  
  17. int main() {
  18.     int* q;
  19.     int trouble[3];
  20.     trouble[0] = 1;
  21.     q = &trouble[1];
  22.     *q = 2;
  23.     trouble[2] = 3;
  24.     hardToFollow(q, trouble[0], &trouble[2]);
  25.     unknown(&trouble[0], *q);
  26.     std::cout << *q << ", " << trouble[0];
  27.     std::cout << ", " << trouble[2] << std::endl;
  28.     getchar();
  29.     return 0;
  30.     //3, 5, 1
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement