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
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
1011Before 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.
4344int * p1, p2;
4445```
4546Here, 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