Skip to main content
added 71 characters in body
Source Link
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.

And *&num is plain num, as the operators cancel out each other.

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.

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.

And *&num is plain num, as the operators cancel out each other.

added 174 characters in body
Source Link
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.

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

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.

Source Link
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