-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseofpointeradd.c
More file actions
73 lines (63 loc) · 2.04 KB
/
useofpointeradd.c
File metadata and controls
73 lines (63 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Pointer : Demonstrate the use of & and * operator :
--------------------------------------------------------
m = 300
fx = 300.600006
cht = z
Using & operator :
-----------------------
address of m = 0x7ffda2eeeec8
address of fx = 0x7ffda2eeeecc
address of cht = 0x7ffda2eeeec7
Using & and * operator :
-----------------------------
value at address of m = 300
value at address of fx = 300.600006
value at address of cht = z
Using only pointer variable :
----------------------------------
address of m = 0x7ffda2eeeec8
address of fx = 0x7ffda2eeeecc
address of cht = 0x7ffda2eeeec7
Using only pointer operator :
----------------------------------
value at address of m = 300
value at address of fx= 300.600006
value at address of cht= z
*/
#include <stdio.h>
int main()
{
int m = 300, *iptr;
float fx = 300.600006, *fptr;
char cht = 'z', *chptr;
printf("\nPointer : Demonstrate the use of & and * operator : \n");
printf("--------------------------------------------------------\n");
printf("m = %d\n", m);
printf("fx = %f\n", fx);
printf("cht = %c\n", cht);
printf("Using & operator : \n");
printf("----------------------- \n ");
iptr = &m;
fptr = &fx;
chptr = &cht;
printf("address of m = %p\n", &m);
printf("address of fx = %p\n", &fx);
printf("address of cht = %p\n", &cht);
printf("Using & and * operator : \n");
printf("----------------------- \n ");
printf("value at address of m :%d\n", *(&m));
printf("value at address of fx :%f\n", *(&fptr));
printf("value at address of cht:%c\n", *(&chptr));
printf("Using only pointer variable :\n");
printf("-----------------------\n ");
printf("address of m =%p\n", iptr);
printf("address of fx =%p\n", fptr);
printf("address of cht =%p\n", chptr);
printf("Using only pointer operator :\n");
printf("-----------------------\n ");
printf(" value at address of m = %d\n", *iptr);
printf("value at address of fx :%f\n", *fptr);
printf("value at address of cht :%c\n", *chptr);
return 0;
}