CHAPTER 20 / 26
C Pointers
Understand pointers, addresses and how pointers access memory.
01 — Syntax
data_type *pointer;
02 — Example
#include <stdio.h>
int main() {
int number = 10;
int *ptr = &number;
printf("Value = %d", *ptr);
return 0;
}03 — Important Points
- A pointer stores an address.
- Use & to obtain an address and * to dereference a pointer.
04 — Common Mistakes
- Dereferencing an invalid pointer.
- Forgetting to initialize a pointer.
- Confusing * with &.
05 — Real-World Use
Pointers are central to memory access, arrays, structures and systems programming.
06 — Practice
Create a small program that demonstrates the main idea of C Pointers.