forked from gouravthakur39/beginners-C-program-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pointers.c
30 lines (24 loc) · 736 Bytes
/
Pointers.c
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
/*
* Handling of pointers in a C program
* A pointer in the C language is an object that stores the address of another
* object.
* A pointer in C is used to allocate memory dynamically i.e. at run time.
*/
#include <stdio.h>
int main(void) {
int * pc; /* the '*' is used to make pointer */
int c;
c = 22;
printf("Address of c: %p\n", (void * ) & c);
printf("Value of c: %d\n\n", c);
pc = & c;
printf("Address of c: %p\n", (void * ) pc);
printf("Content of c: %d\n\n", * pc);
c = 11;
printf("Address of c: %p\n", (void * ) pc);
printf("Content of c: %d\n\n", * pc);
* pc = 2;
printf("Address of c: %p\n", (void * ) & c);
printf("Value of c: %d\n\n", c);
return 0;
}