Operations on Pointers

Operator (&) address: This operator is a unary operator.Operand must be the name of a variable that has previously been defined.The variable’s address number is provided by the & operator.& is likewise referred to as the “Referencing Operator.”

Here is an illustration of how to use the operator’s address.

#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

Operator for indirection (*):

The operator for indirection is *.Another name for it is the “Dereferencing Operator.”The operator is also unary.It uses an address as a justification.* returns the content or container whose argument is its argument’s address.

#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.

Shubhajna Rai
Shubhajna Rai

A Civil Engineering Graduate interested to share valuable information with the aspirants.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in