• Home
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React.js
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
    • TypeScript
      • Introduction to TypeScript
      • TypeScript Developer
    • React
      • Introduction to React
      • React Developer
    • Python
      • Introduction to Python
      • Python Developer
    • C++
      • Introduction to C++
      • C++ Developer
    • C Language
      • Introduction to C
      • C Developer
    • Rust
      • Introduction to Rust
      • Rust Developer
    • Zig
      • Introduction to Zig
      • Zig Developer
    • Linux Shell
      • Introduction to the Linux Shell
      • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Reading Grounds

Quick Links

  • About Us
  • Pricing
  • Partnership
  • Brainstorm
  • Terms
  • Privacy
  • Refunds
  • Featured on DanielLaunches

Courses

  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer

Newsletter

Subscribe to our free monthly newsletter, for a quick update on Python, JavaScript, and React news

© 2025 - 2026 STEMTrainingGrounds. All Rights Reserved.

C Developer -

Lesson 3 of 40

Lesson Progress: 0%

Lesson Progress: 0%
Lesson Incomplete
← Previous: Address-of Operator
Lesson 3 of 40
Next: Pointer Variables →

The dereference operator * (also called the indirection operator) is used with pointers to access the value stored at a memory address. If you have a pointer that stores the address of a variable, writing *pointerlets you read or modify that variable indirectly. It is called "dereferencing" because you are following the reference (address) to get to the actual data. The dereference operator can appear on the right side of an assignment (to read a value) or on the left side (to write a new value). Mastering dereferencing is key to understanding how pointers work in C.

Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    printf("%d\n", *p);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • int* p = &x; makes p point to x by storing its address.
  • *p dereferences the pointer to read the value stored at that address.
  • The value 5 is retrieved from x and printed.
  • Dereferencing is how you access the data that a pointer is pointing to.
  • Without dereferencing, p alone would print a memory address, not 5.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    *p = 15;
    printf("%d\n", x);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The dereference operator can appear on the left side of an assignment to write a value.
  • *p = 15; writes the value 15 into the memory location p points to.
  • This changes x from 5 to 15, even though the code never mentions x directly.
  • printf("%d\n", x); prints 15, confirming the change.
  • Using *p = value; is a common way to modify a variable through a pointer.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    int y = *p;
    printf("%d\n", y);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • You can dereference a pointer and store the value in another variable.
  • int y = *p; reads the value at p (which is 5) and copies it into y.
  • y is an ordinary int, not a pointer. It holds a copy of the value.
  • Changing y later would not affect x, because y is a separate variable.
  • Dereferencing to read a value is like peeking into the box that the pointer points to.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    *p = *p + 3;
    printf("%d\n", x);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • You can use the dereference operator inside an arithmetic expression.
  • *p = *p + 3; reads the current value (5), adds 3, and writes the result back.
  • This modifies x through the pointer, changing it from 5 to 8.
  • The expression *p + 3 dereferences p to get 5, then adds 3.
  • The final value of x is 8, printed by printf.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    int* q = p;
    *q = 20;
    printf("%d\n", *p);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • When you copy a pointer int* q = p;, both p and q point to the same variable.
  • *q = 20; dereferences q and writes 20 into the shared memory location.
  • Since q and p point to the same place, *p now also reads 20.
  • This demonstrates that changes through one pointer are visible through all pointers to the same address.
  • The output is 20, showing that the value was successfully changed through q.
Code Example
#include <stdio.h>

int main() {
    int arr[3] = {10, 20, 30};
    int* p = arr;
    printf("%d\n", *p);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • The name of an array arr acts like a pointer to its first element.
  • int* p = arr; assigns the address of the first element to p. No & needed.
  • *p dereferences the pointer and gives the first element 10.
  • Arrays and pointers are closely related in C — an array name decays to a pointer in most contexts.
  • Dereferencing an array pointer is a common way to iterate through array elements.

Test Incomplete

What does the * operator do when placed before a pointer variable?

Question #

1/15

Score

0/0 - 0.0 %