🌟 Join our Telegram group for exclusive updates! Join Now Get Involved

Operations on Pointers

Operations on Pointers

Address of Operator (&)

  • It is a unary operator.
  • Operand must be the name of an already defined variable.
  • & operator gives the address number of the variable.
  • & is also known as the “Referencing Operator”.

Here’s one example to demonstrate the use of the address of the operator.

#include <stdio.h>

int main()
{
    int a = 100;
    printf("%d\n", a);
    printf("Address of variable a is %d", &a);
    return 0;
}

Output:

100
Address of variable a is 6422220

Indirection Operator (*)

  • * is an indirection operator.
  • It is also known as the “Dereferencing Operator”.
  • It is also a unary operator.
  • It takes an address as an argument.
  • * returns the content/container whose address is its argument.

Here’s one example to demonstrate the use of the indirection operator.

#include <stdio.h>

int main()
{
    int a = 100;
    printf("Value of variable a stored at address %d is %d.", &a, *(&a));
    return 0;
}

Output:

Value of variable a stored at address 6422220 is 100.

Cookies Consent

This website uses cookies to ensure you get the best experience on our website.

Cookies Policy

We employ the use of cookies. By accessing BYTEFOXD9, you agreed to use cookies in agreement with the BYTEFOXD9's Privacy Policy.

Most interactive websites use cookies to let us retrieve the user’s details for each visit. Cookies are used by our website to enable the functionality of certain areas to make it easier for people visiting our website. Some of our affiliate/advertising partners may also use cookies.