Skip to main content
2 of 3
added 174 characters in body
Some programmer dude
  • 411.4k
  • 36
  • 420
  • 655

The value of pnum is the value of &num, i.e. the location of the variable num. Therefore &num and pnum will print the same.

To make it easier to understand and visualize, I recommend you draw it all out:

 +-------+ +------+ +-----+ | &pnum | ---> | pnum | ---> | num | +-------+ +------+ +-----+ 

That is:

  • &pnum is pointing to pnum
  • pnum (which is the same as &num) is pointing to num

Also, the pointer-to operator & and the dereference operator * are each others opposites.

So pnum is the value of &num. And *pnum is the value of num.

Some programmer dude
  • 411.4k
  • 36
  • 420
  • 655