I have code as below :
unsigned int* Adc = 0x2000;
As my understanding the address of ADC is 0x2000, is it right ?
And if I want to assign value to Adc, i just write like this :
Adc = 88;
Is it correct or not ?
I have code as below :
unsigned int* Adc = 0x2000;
As my understanding the address of ADC is 0x2000, is it right ?
And if I want to assign value to Adc, i just write like this :
Adc = 88;
Is it correct or not ?
As my understanding the address of ADC is 0x2000, is it right ?
Almost, unsigned int* Adc = 0x2000;
initializes Adc
with that value. If 0x2000 is not a valid value to assign that pointer, the result is undefined behavior (UB), so hopefully there is some system dependent info indicating this is a valid address for an unsigned
pointer.
The pointer Adc
exists someplace in memory at some address. The address of Adc
makes little difference to your goal.
To be clear, the pointer Adc
has a value of 0x2000 and Adc
exist someplace in memory at some address.
Is it correct or not ?
Not quite. Adc = 88;
assigns a new value to the pointer Adc
from its original 0x2000
.
To change the memory pointed to by Adc
, de-reference it: *Adc = 88;