0 day streak
c / beginner
Snippet

Pointer Basics and Addresses

Pointers are variables that store the memory address of another variable. The '&' operator gets the address, and the '*' operator (dereferencing) accesses the value stored at that address.

snippet.c
c
1
2
3
int count = 5;
int *p = &count;
int value = *p;
Breakdown
1
int count = 5;
Declares a standard integer variable.
2
int *p = &count;
Declares a pointer 'p' and assigns it the memory address of 'count' using '&'.
3
int value = *p;
Uses '*' to dereference the pointer, copying the value from the address stored in 'p' into 'value'.