ABR example

#include <iostream.h>

#include <windows.h>

 

int

main(int, char **)

{

    int *ptr = new int[2];          //Allocate memory for 2 ints

    ptr[0] = 0;

    ptr[1] = 1;

    for (int i=0; i <= 2; i++) {    //Bug: print 3 ints, not 2

        //ABR when i is 2

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

    }

    delete[] ptr;

    return(0);

}

(C) Copyright IBM Corporation 1992, 2010.