In computer programming, a dereference operator, also known as an indirection operator, operates on a pointer variable and returns the location value, or l-value, that it points to in memory. In the C programming language, the deference operator is denoted with an asterisk (*).
int x; int *p;
Now we can set p to the location allocated for the value of x using the & operator, which means "address of."
p = &x;
This action tells the compiler, "The address in memory that p points to is the address that you allocated for the integer x."
To illustrate, if we set the value of x to 1 using the conventional method, and print the value, the output will be 1.
x = 1; printf("%d", x);
However, we can also change the value of x by referencing p. We do this with an asterisk:
*p = 2; printf("%d", x);
And the output changes to 2.
In other words, after p has been declared as a pointer of the same type as x and then set to point to x's value, we can use x and *p interchangeably. Since they both refer to the same thing, changing the value of one will change the value of the other.