Menu
Coddy logo textTech

What is a Pointer?

Part of the Logic & Flow section of Coddy's C journey — lesson 1 of 63.

Think of your computer's memory like a giant apartment building with thousands of rooms. Each room has a unique address, and each room can store one piece of data. When you create a variable in C, it gets assigned to one of these rooms.

A pointer is a special type of variable that doesn't store regular data like numbers or characters. Instead, it stores the address of another variable's memory location. Think of it like writing down someone's apartment number on a piece of paper - the paper doesn't contain the person, but it tells you exactly where to find them.

int age = 25;        // This creates a variable 'age' in memory
int *ptr;            // This creates a pointer that can store an address

In this example, age is stored at some memory address (let's say room 1004), and ptr is a pointer variable that could store the address 1004 to "point to" the age variable.

Pointers are one of C's most powerful features because they allow you to directly work with memory addresses, making your programs more efficient and enabling advanced techniques like dynamic memory allocation and complex data structures.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Logic & Flow