I'm a beginner in C++ programming I have a text file which has 1 million prime numbers separated by spaces. I want to put them in an int array primes[]. Following is the code that I have written:
int main()
{
    ifstream infile;
    infile.open("C:/Users/DELL/Desktop/primes1.txt");
    //check for error
    if(infile.fail()){cerr<<"Error Opening File"<<endl;
    exit(1);}
    int i=0;
    primes = new int[1000001];
    while(i != infile.eof()){
        infile>>primes[i];
        i++;
    }
    cout<<  primes[4]  <<endl;
    return 0;
}
When I build and run, it gives the following error:
"Error: 'primes' was not declared in this scope"
What is the solution to this?
 
     
     
    