example1_basic_usage.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

void processPointer(int* ptr) {
    if (ptr == nullptr) {
        std::cout << "Null pointer received\n";
    } else {
        std::cout << "Value: " << *ptr << "\n";
    }
}

int main() {
    int* p1 = nullptr;
    int value = 42;
    int* p2 = &value;

    processPointer(p1);
    processPointer(p2);

    return 0;
}
Back to nullptr