c++ - Error while deleting dymamic array -


while deleting array, program stops working. if run debug, next error appears: screenshot. code:

#include <iostream> using namespace std; void main(){     int *a=new int[10],*i=new int(0),*j=new int(0),start=0,*m=new int(1),*w=new int(0);     for(;*i<10;(*i)++){         cout << (*i)+1 << " >> ";         cin >> a[*i];         if(*w==2 && a[*i]>-1)             *w=1;         if(a[*i]<0 && *w!=1 && i!=0 && a[(*i)-1]<0){             (*m)++;             *w=2;             start=(*i)-1;         }     }     if(*w==1){         int *temp = new int[*m];         for(*i=0;*i<10-*m;(*i)++,(*j)++){             if(*i==start)                 *j+=*m;             temp[*i]=a[*j];         }         delete []a;//error while debugging here         int *a = new int[*m];         a=temp;         for(*i=0;*i<*m;(*i)++)             a[*i]=temp[*i];         delete[]temp;     }     for(*i=0;*i<10;(*i)++)         cout << (*i)+1 << " >> " << a[*i] << endl; } 

i'm using windows 10 32 bit , visual studio 2010 express


Comments