Why is the code showing a segmentation fault??
#include<bits/stdc++.h>
using namespace std;
const int N =100000;
int p[N+1]={0};
vector primes;
void primeSieve()
{
for(int i=3;i<N;i+=2)
{
p[i]=1;
}
primes.push_back(2);
for(int i=3;i<N;i+=2)
{
if(p[i]==1)
{
primes.push_back(i);
for(int j=i*i;j<N;j+=2*i)
p[j]=0;
}
}
}
int main() {
primeSieve();
int t;
cin>>t;
while(t–)
{
int m,n;
cin>>m>>n;
bool segment[n-m+1];
for(int i=0;i<n-m+1;i++)
segment[i]=0;
for(auto x:primes)
{
if(x*x>n)
break;
int start=(m/x)*x;
if(x>=m && x<=n)
start=x*2;
for(int i=start;i<=n;i+=x)
segment[i-m]=1;
}
for(int i=m;i<n;i++)
{
if(segment[i-m]==0 && i!=1)
cout<<i<<endl;
}
cout<<endl;
}
return 0;
}