C Address and Dereference

Intermediate
6 min read
Updated: Nov 2026
1 example

What Is Address and Dereference?

The address-of operator & gives the address of an object. The dereference operator * follows a pointer to the object it points to, usable on either side of an assignment. They are inverses: *&x is x.

Remember
&x       /* address of x          */
*p       /* object p points to     */
*p = 5;  /* write through pointer  */
y = *p;  /* read through pointer   */

Cheat Sheet

Keep these facts handy while you work with Address and Dereference in C.

TopicDetail
&Needs an lvalue (variable, element, member)
*Needs a valid pointer
Inverse*(&x) is x
Struct memberp->m is (*p).m

C Examples

Compile each example with gcc file.c -std=c11 -Wall -o out. Next: Pointer Arithmetic.

Example 1 — Two pointers to the same variable

Writes through either pointer are seen by both.

C
#include <stdio.h>

int main(void) {
    int n = 7;
    int *a = &n;
    int *b = &n;

    *a = *a + 1;
    printf("n = %d\n", n);
    *b = *b * 10;
    printf("n = %d, *a = %d\n", n, *a);
    printf("a == b: %d\n", a == b);
    return 0;
}

How It Works

  1. a and b hold the same address.
  2. *a + 1 makes n 8; *b * 10 makes it 80.
  3. Pointer equality compares addresses.

Edge Cases & Pitfalls

Check these before relying on Address and Dereference in real programs.

rvalue

Taking the address of a value

&5 and &(a + b) are invalid because they are not objects.

prec

Precedence of *p++

*p++ reads *p then moves p. Use (*p)++ to increment the value.

Key Takeaways

  • &: object to address.
  • *: address to object.
  • Parentheses: (*p)++ vs *p++.

One line: The address-of operator & gives the address of an object.

Frequently Asked Questions

In an expression, * dereferences a pointer to access the object it points to. In a declaration, it marks the variable as a pointer.
& produces an address; * follows an address. They undo each other.
Continue with "C Pointer Arithmetic" next. Add, subtract, and compare pointers to move through memory. The C Pointers hub lists every topic in order.

Next: Pointer Arithmetic

Add, subtract, and compare pointers to move through memory.

Continue →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful