Home › C++ Tutorial › C++ pointers
C++ pointers
Variables that store addresses.
&x is the address, *p reads the value there. A pointer can change targets and can be nullptr.
Example code
#include <iostream>
using namespace std;
int main() {
int x = 5;
int *p = &x;
*p = 8;
cout << x << " " << *p << " " << (p != nullptr) << endl;
return 0;
}