f(x)
Pointers — Part 1
🏠 Home Lecture 18: Pointers Intro
The Big Secret

Arrays = Pointers in Disguise

When you create an array in C, the name of the array actually acts as a pointer to its first element (index 0).

arrays_and_pointers.c
int lineup[5] = {1, 66, 4, 11, 9}; // These two print the exact same address! printf("%p\n", lineup); printf("%p\n", &lineup[0]);

💡 Concept Question

If lineup is an array, what do you think *lineup will print?
The memory address
The value 1
The entire array
An error
Pointer Math

Pointer Arithmetic (ptr + 1)

Pointers are smart! When you add 1 to a pointer, it doesn't just add 1 byte. It moves forward by the exact size of the data type it points to.

pointer_math.cMoving Through Memory
int lineup[5] = {1, 66, 4, 11, 9}; int *ptr = lineup; // Points to 1 printf("Current: %d\n", *ptr); // Prints 1 // Move pointer to next player ptr = ptr + 1; printf("Next: %d\n", *ptr); // Prints 66

⏩ Jumping Addresses

If ptr is at address 1000, and it points to an int (4 bytes), then ptr + 1 will automatically point to address 1004!
ANFIELD STARTING XI 🏟️ 2026-27

Traversing the Array (ptr++)

All 11 Liverpool players stored as int lineup[11] — 4 bytes apart in memory. Hit Execute ptr++ to step through each one!

*ptr
↓
lineup[0] = 1 | Address: 1000 | Alisson Becker (GK)
Knowledge Check

Test Your Understanding

Question 1 of 5
Loading question...