Dereference Pointer in C

Accessing or manipulating the content that is stored in the memory address pointed by the pointer using dereferencing or indirection operator (*) is called dereferencing the pointer.

Dereferencing Pointer in C

Syntax for Dereferencing a Pointer

We use the indirection operator (*) as the prefix to dereference a pointer:

*(pointer_name)

For modifying the data stored in the memory, we use

*(pointer_name) = new_value;

It is to be noted that the new_value must be of the same type as the previous.

Consider the above examples where ptr points to num, the content in the memory address can be accessed by the dereferencing operator *. Now, the *ptr will fetch the content stored in the address which is 10.

The num and ptr memory address and values will look like this.

Variable Memory Address Value
num = 10 202020 10
202021
202022
202023
ptr = &num 202024 – 202032 202020

Note: We have assumed that the architecture in the above example is byte addressable i.e. minimum unit that has a separate address is a byte.

Dereference Pointer in C

We know that the pointer variable can store the memory address in C language and in this article, we will learn how to use that pointer to access the data stored in the memory location pointed by the pointer.

Similar Reads

What is a Pointer?

First of all, we revise what is a pointer. A pointer is a variable that stores the memory address of another variable. The pointer helps us to manipulate the data in the memory address that the pointer points. Moreover, multiple pointers can point to the same memory....

Dereference Pointer in C

Accessing or manipulating the content that is stored in the memory address pointed by the pointer using dereferencing or indirection operator (*) is called dereferencing the pointer....

Examples of Pointer Dereferencing

Example 1:...

How dereferencing work?

...