Introduction to Pointers

Pointers are variables that store the memory address of another variable.

int x = 10;
int* ptr = &x;  // ptr stores the address of x

cout << *ptr;   // Dereferencing: prints the value at the address (10)

Pointers are powerful but must be used carefully to avoid memory issues.

← PrevNext →