Hi, I'm just after a bit of clarification here. Been fiddling with pointers, trying to get familiar with them and understand exactly what they do and how they operate. Here is the code:
Code:
#include <stdio.h>
int main()
{
int *pCake;
int dog;
dog = 25;
pCake = &dog;
printf("Should return 25 / pCake dereferenced(*pCake): %d\n", *pCake);
printf("Prints dog's address %d\n", &dog);
printf("Should return dog's address (pCake): %d\n", pCake);
printf("Print pCake's address: %d\n", &pCake);
return 0;
}
This code returns this when run:
Should return 25 / pCake dereferenced(*pCake): 25
Prints dog's address -1074293652
Should return dog's address (pCake): -1074293652
Print pCake's address: -1074293648
( ^^^ This is the address at which the pointer(pCake is located?).
Now as far as I can see everything is written correctly, and I'm pretty confident it's right, I'm just wondering if I'm on the right track :P. Is there anything wrong with what I've done, are the address correct? Also, why are the addresses followed by a hyphen "-"?
Thanks.