I'm having trouble deleting these two pointers:
int *p = new int;
char * string1 = new char[20];
char * string2 = new char[25];
strcpy(string1, "Sheldon");
string2 = string1;
delete p;
delete[] string2; //this works without the next line
delete[] string1; //when I add this, it fails at string2 = string1
I'm using the memory leak detection with
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
When I run he program without "delete[] string1," it gives me "{66} normal block at 0x0075E300, 25 bytes long." So "delete[] string2" is deleting string1. Which doesn't make sense to me, but I'm guessing it has to do with the assignment. I tried looking up stuff about it, but nothing has worked.