All is correct.
1st line: you declare two variables
Second line: memory pointer "ip" defined
Third line: memory address X is assigned to the ip pointer
4th line: Y is now set to the value of the variable X at ip
The memory address, however, is in hexadecimal format. 011001110 is a data byte, not a memory address. The address will most likely be approximately 0x000000000022FE38 (it may be shorter). Consider this:
int x = 0; int *ptr = &x; //the "&" character means "the address of" printf("The variable X is at 0x%p and has the value of %i", (void *)ptr, x);
This will print the address of X, not * ptr. You will need another pointer to print the address * ptr. But this is pretty pointless since the pointer is defined to print the address of the variable. Think of it as an alias for another variable (this value is the value at this memory address).
Adrian zhang
source share