Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A null pointer is a pointer that doesn't point to any valid memory location. It represents the "empty" or "not set" state.
int* ptr = nullptr;Always use nullptr instead of NULL or 0. It is type-safe and prevents ambiguity with integer types.
if (ptr != nullptr) {
cout << *ptr; // Safe to dereference
} else {
cout << "Pointer is empty";
}Dereferencing a null pointer (*ptr when ptr is null) will cause your program to crash immediately. This is the most common cause of "Segmentation Fault".