int main() { int* i = new int(1); i++; *i=1; delete i; }
Here is my logic:
I increment I by 1, and then assign a value to it. Then
The problem lies here:
i++;
This line doesn't increment the value i points to, but the pointer itself by the number of bytes an int has (4 on 32-bit platform). You meant to do this:
i
int
(*i)++;