Ad space (banner)
๐Ÿ”งC Lessons
Lesson 16 / 68

Pointer Basics

This lesson covers the basics of pointers in C, so you understand the idea of directly working with a variable's address. It's for anyone searching "C pointer usage."

A pointer is a special variable that holds the "address" in memory where a variable is stored. Get a variable's address with &, and access the value a pointer points to with *. This is one of the most important concepts for understanding C, and one you can't avoid.

The example assigns num's address to the pointer p with int *p = #, and accesses the value p points to with *p. Setting *p = 20; lets you rewrite the original num's value through the pointer.

A common early mistake is confusing & (the address-of operator) with * (the dereference operator). Mixing up what these two symbols mean makes a pointer's behavior confusing to follow.

In real projects, understanding pointers is foundational to C programming โ€” efficiently passing large data to a function, dynamically allocating memory, and more.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run C directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)