Figure 2: Memory overwrite in C++

/* To compile: CRTBNDCPP PGM(EXAMPLE2) */
#include <string.h>

int main (int argc, char *argv[])
{
  char *ptr = new char[16];

  /* strcpy() copies the trailing NULL character */
  strcpy(ptr, "abcdefghijklmnop");  /* memory overwrite */
  delete [] ptr;
  return 0;
}