Indirection Operator in C

In this class, we will try to understand Indirection Operator in C.

Indirection Operator in C

We have understood the concept of pointer variables and visualization of pointer variables in our previous class.

Indirection Operator [*]

Once the pointer variable points to an object, we can use the indirection operator [*] to access what’s stored  in the object.

The image below has the programming lines to understand the concept of Indirection Operator.

Indirection Operator in C Example
Indirection Operator in C Example

The visualization of the first four lines of code in red is as shown in the image below.

Visualization of Pointer Variable in C Fourth Line
Visualization of Pointer Variable

Generally we can access the values of a variable as shown in the fifth line.

In C, we can access the value to which the pointer variable is pointing.

This kind of access is done by using the indirection operator.

The sixth line of the code is how we access the value stored in a variable.

Not only to access but to modify or update, we can use the indirection operator.

The seventh line of code shows how to modify the value by using the indirection operator.