One of the issues I am having is attempting to cast variables into memory to be accessed at later points.
I have an example code here that works perfectly:
unsigned int *label = (unsigned int *)malloc(sizeof(unsigned int));
label = (unsigned int * ) 0xFFAAFFAA;
Anywhere else in my code I can access this value label, and it will be pointing to 0xFFAAFFAA as its value when I try to print it.
However, if I try to assign from a variable like such:
//all of this is inside a method.. so any variables declared would be local
unsigned int localVariable = 0xFFFFFFFF;
unsigned int *label = (unsigned int *)malloc(sizeof(unsigned int));
label = &localVariable;
The result will be something crazy like: 0x7f252d6b5f00 .. which I am just assuming is some random address in memory. I know this issue is because of a local variable as that operates within a function and is not global. But I can't figure out what the syntax of this would be...
The reason I want to define the local variable is because there is other logic in the function to add and subtract from that variable.. I left it out to keep it minimal
EDIT: so I could do something like this?
unsigned int localVariable = 0xFFFFFFFF;
unsigned int *label = (unsigned int *)malloc(sizeof(unsigned int));
*label = localVariable;