c / beginner
Snippet
Basic Pointer Declaration
A pointer is a variable that stores the memory address of another variable. The ampersand (&) operator retrieves the address.
snippet.c
1
int val = 5; int *ptr = &val;
Breakdown
1
int *ptr
Declares a pointer variable 'ptr' that points to an integer.
2
&val
The address-of operator, which gets the memory location of 'val'.