I got a problem with the memset funciton Here is part of the code Code1
int main()
{
    long long int num=600851475143;
    bool factor[5000];
    //memset(factor,true,sizeof(factor));
    primer_factor_find(factor);
    int largest=largest_primer_factor(num,factor);
    cout<<largest<<endl;  
    return 0;
}
void primer_factor_find(bool factor[])
{
    memset(factor,true,sizeof(factor));
    int j,k;
    for(j=1;j<=2500;j++)
        for(k=3*j+1;k<=5000;k+=(2*j+1))
            factor[k]=false;
}
the only difference between Code2 is the location of the memset function.(In Code2,memset is in the main) I find Code1 doesn't work at all.Code2 works fine.What's the matter?
 
     
     
    