1. ## Infinite loop?

#include <iostream.h>
#include <math.h>

void determinePrimes(int);
inline bool isPrime(int, int*);

int main()
{
int maxPrime;

cin >> maxPrime;

determinePrimes(maxPrime);
cout << "Done.";

return 0;
}

void determinePrimes(int maxPrime)
{
int *primes = new int[1.1 * (maxPrime / log10(maxPrime))]; primes[0] = 2;

for (int j = 3; j <= maxPrime; j += 2)
if (isPrime(j, primes)) primes[j-3] = j;

delete[] primes;
}

inline bool isPrime(int number, int *primes)
{
for (int j = 0; primes[j] < sqrt(number); ++j)
if (number % primes[j] == 0) return 0;
return 1;
}

----
Why does this program crash? It's not making sense to me. I think I've deleted all my pointers and I think I'm not trying to access any arrays out of bounds...

2. ## This is what it should look like in the first post...

Code:
```#include <iostream.h>
#include <math.h>

void determinePrimes(int);
inline bool isPrime(int, int*);

int main()
{
int maxPrime;

cin >> maxPrime;

determinePrimes(maxPrime);
cout << "Done.";

return 0;
}

void determinePrimes(int maxPrime)
{
int *primes = new int[1.1 * (maxPrime / log10(maxPrime))]; primes[0] = 2;

for (int j = 3; j <= maxPrime; j += 2)
if (isPrime(j, primes)) primes[j-3] = j;

delete[] primes;
}

inline bool isPrime(int number, int *primes)
{
for (int j = 0; primes[j] < sqrt(number); ++j)
if (number % primes[j] == 0) return 0;
return 1;
}```

3. >I think I've deleted all my pointers and I think I'm not trying to access any arrays out of bounds...

The error is in this statement
primes[j-3] = j;
Apparently it's an access violation. Your best bet would be to do a paper run of your program and calculate everything by hand to make sure that you're not trying to access a memory location that is outside of the array.