Nearby lessons
90 of 124C - Dereference Pointer (*)
Dereference Pointer (*) is one of the foundational topics in C programming. This lesson explains The Two Pointer Operators, Program 1: see & and * working and Complete Program 2 — Change a Value Through a Pointer with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
The Two Pointer Operators
| Operator | Name | What it does |
|---|---|---|
| & | Address-of operator | Gives the memory address of a variable |
| * | Indirection / dereference | Goes to the address and gives the value stored there |
Program 1: see & and * working
Trainer's Note: Memory trick: `&` reads 'address of', `*` reads 'value at'. So p = &a puts a's address in p, and *p gives back a's value. Beginners often mix them — practise this one program until it is clear.
Example02
Complete Program 2 — Change a Value Through a Pointer
Using *p you can read or change the value at that address:
Example03
📝 Key Takeaways
- A pointer stores the address of a variable; it 'points to' it.
- & gives the address; * gives the value at an address.
- Each concept has its own program: & and *, change via pointer, arrays, swap, NULL.
- Array name = address of the first element; *(p+i) walks the array.
- Call by reference uses & and * so a function can change original variables.
- Swap is the classic call-by-reference example.
- Always check for NULL before using a pointer.
- (Advanced pointer topics — pointers to functions, linked lists — are beyond beginner scope.)
🧠 Test Your Knowledge
1 QuestionsProgress: 0 / 1