Skip to content

Commit 41a4683

Browse files
authored
Update Pointer.md
1 parent 30535b5 commit 41a4683

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Pointer.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ C pointers are simple and enjoyable to learn.Some C programming tasks are easier
55
* [Addresses in C](#addresses-in-c)
66
* [What is Pointer?](#what-is-pointer)
77
* [Pointer Syntax](#pointer-syntax)
8+
* [Get value of things Pointed by Pointer](#get-value-of-things-pointed-by-pointer)
89

910
## Addresses in C
1011
Before we get to the definition of pointers, let us understand what happens when we write the following code:
@@ -43,3 +44,17 @@ Let's take another example of declaring pointers.
4344
int* p1, p2;
4445
```
4546
Here, we have declared a pointer p1 and a normal variable p2.
47+
48+
## Get Value of things Pointed by Pointers
49+
To get the value of the thing pointed by the pointers, we use the * operator. For example:
50+
```c
51+
int* pc, c;
52+
c = 5;
53+
pc = &c;
54+
printf("%d", *pc); // Output: 5
55+
```
56+
Here, the address of c is assigned to the pc pointer. To get the value stored in that address, we used *pc.
57+
58+
*Note: In the above example, pc is a pointer, not * pc. You cannot and should not do something like * pc = &c;*
59+
60+
*By the way, * is called the dereference operator (when working with pointers). It operates on a pointer and gives the value stored in that pointer.*

0 commit comments

Comments
 (0)