example3_null_pointer.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include <iostream>

int main() {
    int* ptr = nullptr;  // 'ptr' is a null pointer

    if (ptr == nullptr) {
        std::cout << "ptr is null." << std::endl;
    }

    return 0;
}
Back to raw_pointers