• 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 1 of 40

Lesson Progress: 0%

Lesson Progress: 0%
Lesson Incomplete
Lesson 1 of 40
Next: Address-of Operator →

Pointers are one of the most powerful features in C. A pointer is a variable that stores the memory addressof another variable, instead of storing a value directly. Think of a pointer as a signpost that says "the data you are looking for is over there." You declare a pointer by writing the type followed by an asterisk *, like int* p. The address-of operator & gets the memory address of a variable, and the dereference operator * follows the pointer to access the value stored at that address. Pointers let you indirectly read and modify variables, which is essential for many advanced C techniques.

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 x = 5; creates an integer variable x with value 5.
  • int* p = &x; declares a pointer p that stores the memory address of x.
  • *p dereferences the pointer to get the value stored at the address p points to, which is 5.
  • The %d format specifier prints the dereferenced integer value.
  • This is the simplest example of using a pointer to read a variable indirectly.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    *p = 12;
    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
  • A pointer can be used to modify the variable it points to.
  • *p = 12; dereferences p and assigns a new value (12) to the memory location of x.
  • After this assignment, x itself is changed to 12, even though the code never directly touches x.
  • printf("%d\n", x); prints 12 because the value of x was changed through the pointer.
  • This shows how pointers give you indirect write access to variables.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    int** q = &p;
    printf("%d\n", **q);
    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 create a pointer to a pointer using two asterisks: int** q.
  • int** q = &p; stores the address of the pointer p itself.
  • **q dereferences twice: first *q gets the pointer p, then the second * gets the value 5 from x.
  • This is called multiple indirection and is useful for dynamically allocated data structures.
  • The output is still 5 because all pointers ultimately lead to the same integer.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    int* r = p;
    printf("%d\n", *r);
    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
  • Pointers can be copied into other pointer variables.
  • int* r = p; makes r point to the same address as p, which is the address of x.
  • Both p and r now point to the same variable x.
  • *r dereferences r and prints the value of x, which is 5.
  • Copying pointers does not copy the data — it just creates another reference to the same memory.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    int** q = &p;
    printf("%d\n", **q);
    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
  • This snippet demonstrates a pointer to a pointer again with a different perspective.
  • int** q = &p; stores the address of pointer p in q.
  • **q goes through two levels of indirection to reach the value 5.
  • Pointer-to-pointer is commonly used when a function needs to modify a pointer argument.
  • Even with multiple levels, the final value is the original integer 5.
Code Example
#include <stdio.h>

int main() {
    int x = 5;
    int* p = &x;
    *p = 30;
    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
  • This snippet reinforces modifying a variable through a pointer.
  • *p = 30; writes the value 30 into the memory address stored in p.
  • Since p points to x, the variable x becomes 30.
  • printf("%d\n", x); prints 30, confirming the change was made.
  • This pattern — passing a pointer to a function to allow modification — is one of the most important uses of pointers in C.

Test Incomplete

What does the & operator do in C when placed before a variable like &x?

Question #

1/15

Score

0/0 - 0.0 %