initial import
[staff/goc4/2018bti7061.git] / c-4-pointers / examples / c-pointers / pointers1.c
1 #include <stdio.h>
2
3 main(){
4 int w;
5 int u = 3;
6 int v;
7 int *pu; /* pointer to an integer */
8 int *pv; /* pointer to an integer */
9 int *pw; /* pointer to an integer */
10
11 pu = &u; /* assign address of u to pu */
12 v = *pu; /* assign value of u to v */
13 pv = &v; /* assign addresse of v to pv */
14 pw= &w;
15
16 printf("u = %d &u=%lX pu=%lX *pu=%d\n",u,&u,pu,*pu);
17 printf("v = %d &v=%lX pv=%lX *pv=%d\n",v,&v,pv,*pv);
18 printf("w = %d &v=%lX pv=%lX *pv=%d\n",w,&w,pw,*pw);
19 return 0;
20 }
21 /* Output:
22 u = 3 &u=6e3b6f18 pu=6e3b6f18 *pu=3
23 v = 3 &v=6e3b6f1c pv=6e3b6f1c *pv=3
24 */