What could be the line that can cause SIGABRT error in this prog???
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
long int *b,l=0,i,j,k=2;
long int n,m;
system("CLS");
cin>>n>>m;
long int a[m],y[m];
b=new long int[n];
for(i=0;i<n;i++)
{
if(i<m)
{
cin>>a[i];
}
b[i]=0;
}
b[0]=1;
for(j=0;j<m;j++)
{
y[j]=a[j];
while(y[j]<n)
{
b[y[j]]++;
y[j]=(a[j])*(k);
k++;
}
k=2;
}
for(j=0;j<n;j++)
{
if(b[j]==0)
{l++;}
}
cout<<endl<<l;
system("PAUSE");
return 0;
}
CLS on Unix? That won't cause a crash, but it won't do anything either. CLS is a builtin command in the DOS/Windows command line shell. You shouldn't be using system() in general.
If you use vectors instead of arrays, and replace [] with .at(), it'll tell you where it's going wrong. Plus you'll get variable sized containers.