My sieve code is throwing some error not showing the correct anwer

#include
#define ll long long int
using namespace std;

void prime_sieve(int *p)
{
for(ll i= 3;i<=1000000;i=i+2)
{
p[i]=1;
}

for(ll i=3;i<=1000000;i=i+2)
{
    if(p[i]==1)
    {
        for(ll j=i*i;j<=1000000;j=j+i)
        {
            p[i]=0;
        }
    }
}

p[0]=0;
p[1]=0;
p[2]=1;

}

int main()
{
int n;
cin>>n;

int p[1000005]={0};
prime_sieve(p);
for(int i=0;i<=n;i++)
{
    if(p[i]==1)
    {
        cout<<i<<" ";
    }
}

}

at line no 18
p[i]=0 this is wrong
correct is
p[j]=0;

check modified Code