ABW example

#include <iostream.h>

#include <windows.h>

 

int

main(int, char **)

{

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

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

        ptr[i] = i;

        cerr << "ptr[" << i << "] == " << ptr[i] << '\n'; //ABW + ABR when i is 2

    }

    delete[] ptr;

    return(0);

}

(C) Copyright IBM Corporation 1992, 2010.