NPR example

#include <iostream.h>

#include <windows.h>

 

int

main(int, char **)

{

    int *ptr = (int *) 0x0; //Bug: null pointer

    for (int i=0; i < 2; i++) {

        //NPR: attempting to access null pointer

        cerr << "ptr[" << i << "] == " << ptr[i] << '\n';

    }

    return(0);

}

(C) Copyright IBM Corporation 1992, 2010.