File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ C pointers are simple and enjoyable to learn.Some C programming tasks are easier
5
5
* [ Addresses in C] ( #addresses-in-c )
6
6
* [ What is Pointer?] ( #what-is-pointer )
7
7
* [ Pointer Syntax] ( #pointer-syntax )
8
+ * [ Get value of things Pointed by Pointer] ( #get-value-of-things-pointed-by-pointer )
8
9
9
10
## Addresses in C
10
11
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.
43
44
int * p1, p2;
44
45
```
45
46
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.*
You can’t perform that action at this time.
0 commit comments