Actually, I think the answer the OP was look for is this:
Given this:
n contains 1, but p doesn't contain 1. p contains the address of the variable n in memory. This might be 0x345dee4 (memory addresses are typically written in hexadecimal), or whatever. It might change every time you run your program.Code:int n = 1;
int *p = &n;
Regardless, you shouldn't care about the exact value that p holds -- you know that it "points" to n, and that's good enough.
*p, on the other hand, tells the compiler to look at p and find the address it holds; and then look at the memory at that address. In effect, it's the same thing as looking at n directly. And thus, *p == 1.
Output of one run on my system:Code:#include <stdio.h>
int main() {
int n = 1;
int *p = &n;
printf("n: %d\n", n);
printf("p: %p\n", p);
printf("*p: %d\n", *p);
return 0;
}
Code:n: 1
p: 0x7fff6017f514
*p: 1