Address Operator & in C

Last Updated : 11 Jul, 2026

The Address Operator in C is a special unary operator that returns the address of a variable. It is denoted as the Ampersand Symbol ( & ).

  • This operator returns an number which is the address of its operand in the memory.
  • We can use the address operator (&) with any type of variables, int, char, array, strings, functions, and even pointers.
address
C
#include <stdio.h>

int main()
{
    // declaring a variable
    int x = 100;

    // printing the address of the variable
    printf("The address of x is %p", &x);
    return 0;
}

Output
The address of x is 0x7fffe8f5591c

Explanation

  • The variable x is initialized with the value 100, and the address-of operator (&) is used to obtain its memory address.
  • The printf() function prints the address using the %p format specifier, which displays it in hexadecimal format.
  • In practice, the address returned by & is usually stored in a pointer variable and can be dereferenced (*) to access the value stored at that memory location.

Example: Program using a pointer to store the address returned by the address operator and then dereferencing it.

C
#include <stdio.h>

int main()
{
    // integer variable
    int x = 1;
    
    // integer pointer
    int *ptrX;
    
    // pointer initialization with the address of x
    ptrX = &x;

    // accessing value of x usin pointer
    printf("Value of x: %d\n", *ptrX);

    return 0;
}

Output
Value of x: 1

Some standard functions like scanf() also require the address of the variable. In these cases, we use the address operator.

C
#include <stdio.h>

int main()
{
    // defining variable
    int number;

    printf("Enter any number: ");
    
    // using adress operator & in scanf() to get the value entered by the user in the console
    scanf("%d", &number);

    // priting the entered number
    printf("The entered number is: %d", number);
    return 0;
}


Output

Enter any number: 10
The entered number is: 10

Note: In C, the address operator (&) cannot be used with some entities like register variables, bit fields, literals, or expressions, because they either do not have a memory address or cannot provide one.

Applications

The address operator (&) is widely used in C programs to get the addresses of different entities. Some of the major and most common applications are:

Limitations

The address operator cannot be applied to every operand.

  • Cannot be used with register variables.
  • Cannot be used with constants or literals.
  • Cannot be used with expressions like (a + b).
  • Cannot be used with bit-fields.
Comment