initial import
[staff/goc4/2018bti7061.git] / c-4-pointers / examples / c-pointers / pointerArithmetic1.c
1 #include <stdio.h>
2
3 int main(){
4 int* px;
5 int i = 1;
6 float f= 0.3;
7 double d=0.005;
8 char c = '*';
9
10 px=&i;
11 printf("Values: i=%i f=%f d=%f c=%c\n",i,f,d,c);
12
13 printf("Addresses: i=%lX f=%lX d=%lX c=%lX\n",&i,&f,&d,&c);
14
15 printf("Pointer Values (size of int = %d):\n px=%lX; px+1=%lX; px+2=%lX; px+3=%lX\n",sizeof(int),px,px+1,px+2,px+3);
16
17 printf("Dereference: at px+1=%lX, value is:%f \n",px+1,*(px+1));
18
19 /* Output :
20 Values: i=1 f=0.300000 d=0.005000 c=*
21 Addresses: i=7FFF13C9C164 f=7FFF13C9C168 d=7FFF13C9C150 c=7FFF13C9C16F
22 Pointer Values (size of int = 4):
23 px=7FFF13C9C164; px+1=7FFF13C9C168; px+2=7FFF13C9C16C; px+3=7FFF13C9C170
24 Dereference: at px+1=7FFF13C9C168, value is:0.300000
25 */
26
27 }