Topic: *p=d vs. p=&d ?
Author: rileyh@u.washington.edu (Riley Hoselton)
Date: 25 May 1994 02:37:11 GMT Raw View
Hi,
Given that p is a pointer to int
and d is a int.
what is the difference between
*p=d
p=&d
Thanks!
rileyh@u.washington.edu
Author: b91926@fsgi01.fnal.gov (David Sachs)
Date: 25 May 1994 10:41:52 -0500 Raw View
rileyh@u.washington.edu (Riley Hoselton) writes:
>Hi,
> Given that p is a pointer to int
>and d is a int.
>what is the difference between
>*p=d
>p=&d
>Thanks!
>rileyh@u.washington.edu
These statements do ENTIRELY different things. To illustrate,
suppose we have a pointer (to integer) p and two integer variables
d1 and d2:
p = &d1; // set p to point to d1
*p = d2; // set object pointed to by p to the value of d2
If the two staements appeared consecutively, d1 would be set
to the value of d2.