Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.c>
int main()
{
int n = 12;
int *np;
np = &n;
int *created = new int;
*created = 1000;
printf("\"np\" points to: %i, which is of course: %i \n\n", *np, n);
printf("\"created\" points to: %i, so where is the variable it points to???\n\n", *created);
created = np; //...Oh no, the integer "1000" is now lost forever...
printf("Re-attaching \"created\" to something else...\n\n");
printf("\"np\" points to: %i, which is of course: %i \n\n", *np, n);
printf("Now \"created\" also points to: %i, so where is the variable it pointed to before?\n Can you see where it went?\n\n", *created);
getch();
return 0;
}