C in 100 Seconds: Pointers | Episode 17
Video: C in 100 Seconds: Pointers — Two Ways to Access the Same Memory | Episode 17 by Taught by Celeste AI - AI Coding Coach
Watch full page →Pointers — Addresses and Values in C
C in 100 Seconds, Episode 17
Pointers are the defining feature of C. A pointer is a variable that holds a memory address. Once you understand pointers, you understand how C really works.
The Two Operators
&— the address-of operator. Gets the memory address of a variable.*— the dereference operator. Gets the value at a memory address.
int x = 42;
int *ptr = &x;
ptr now holds the address of x. The type int * means "pointer to an integer."
Reading a Pointer
printf("Value of x: %d\n", x); // 42
printf("Address of x: %p\n", &x); // 0x7ff...
printf("ptr holds: %p\n", ptr); // same address
printf("Value at ptr: %d\n", *ptr); // 42
ptr and &x are the same address. *ptr follows that address to get the value — which is x.
Writing Through a Pointer
Dereferencing works for assignment too:
*ptr = 99;
printf("x is now: %d\n", x); // 99
We didn't touch x directly. We went through the pointer and modified the value at that address. Since ptr points to x, the change shows up in x.
Why Does This Matter?
Pointers are how C does everything that higher-level languages hide from you:
- Pass by reference — modify variables inside functions
- Dynamic memory —
mallocreturns a pointer - Data structures — linked lists, trees, graphs all use pointers
- Hardware access — memory-mapped I/O is pointer-based
You can't avoid pointers in C. They're not an advanced feature — they're the foundation.
Full Code
#include <stdio.h>
int main() {
int x = 42;
int *ptr = &x;
printf("Value of x: %d\n", x);
printf("Address of x: %p\n", &x);
printf("ptr holds: %p\n", ptr);
printf("Value at ptr: %d\n", *ptr);
*ptr = 99;
printf("x is now: %d\n", x);
return 0;
}
Compile and Run
gcc pointers.c -o pointers
./pointers
Next episode: Pointer Arithmetic — walking through memory one element at a time.
Student code: github.com/GoCelesteAI/c-in-100-seconds/episode17