-2

Let's say I have a following program:

int a=7;  // while &a=0x67a9

Is there a way to change adress of a, to for ex. 0xaa55?

GraphLearner
  • 179
  • 1
  • 2
  • 11

1 Answers1

6

No, that's not possible. The addresses of local variables are registers or stack addresses. So these can even change with every call context.


In case you know that your hardware supports to have a value at that specific address, you can use a pointer though:

volatile int* pa = 0x67a9;

and access the value

std::cout << *pa << std::endl;
user0042
  • 7,917
  • 3
  • 24
  • 39