How to revert pointers

How to revert pointers

So you made a pointer, but want to get it’s value’s value (a.k.a. revert it)?
Well this is the right guide for you!

DISCLAIMER

The creator of this guide is NOT responsible for sight damage caused by pointers, or any security flaws

C

#include <stdio.h> // for printing values

int main() {
  int num = 32;      // making the variable
  int * ptr = &num;  // making the pointer
  int num2 = *ptr;   // cloning the `num` variable (`num` isn't cloned, it's value is)
  printf("Number: %d, Number Clone: %d", num, num2); // "Number: 32, Number Clone: 32"
}

C++

#include <iostream> // for printing values

int main() {
  int num = 32; // making the variables
  int * ptr = &num; // making the pointer
  int num2 = *ptr; // cloning the `num` variable (`num` isn't cloned, it's value is)
  cout << "Number: " << num << ", Number Clone: " << num2 << endl; // "Number: 32, Number Clone: 32"
}
2 Likes