I increased the size and now I am getting segmentation error 18 core dumped

#include
using namespace std;

void prime_sieve(long int a[])
{
a[0]=0;
a[1]=0;
a[2]=1;

//sieve
for(long int i=3 ; i<100000 ; i+=2)
{
if(a[i]==1)
{
for(long int j=i*i ; j<100000 ; j=j+i)
{a[j]=0;}
}
}
}

int main() {

long int a[10000000]={0};
long int n;
cin>>n;
prime_sieve(a);
n–;
if(n==0)
{cout<<‘2’;}

for(int i=3 ; n>0 ; i=i+2)
{
if(a[i]==1)
n–;

if(n==0)
cout<<a[i];
}
return 0;
}

make the array global it will help

if it not work then send the link of code i will check it by running

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.