hey guys, i wrote ths program. it is compiling and working but after it gives me the results i want it gives me an error which says the application wrote to memory after end of heap. i know what it means but i dont know how to solve this . can you help? thank you
#include <iostream>
usingnamespace std;
int
main (int argc, char ** argv)
{
int n=0;
int i=0;
int j=0;
int count=0;
int m=0;
int * a = newint [n];
cout<<"please enter the number of entries you want in your sequence"<<endl;
cin>>n;
cout<<"please enter the sequence of numbers you want"<<endl;
while (i<n){
cin>>m;
a[i]=m;
i++;
}
while (j < (n-2))
{
if ( a[j]==0 && a[j+1]==0 && a[j+2]==1 && j<(n-2) && (j+1)<(n-1) && (j+2)<n)
{
cout<<"this sequence contains a 001"<<endl;
count++;
}
j++;
}
cout<<"the number of times that the sequence 001 was found is"<<endl;
cout<<count;
delete a;
* a= NULL;
return 0;
}