array sizes must be known at compile time.
int primearr[counter]; //can't do it in standard c++
int primearr[25000] = {0}; //we know at most 1/2 are prime. Its more like 10%, if I remember the rule of thumb, so 10k is probably overkill.
for(int i = 0; i <= 50000; i++)
{
if(primecheck(i))
{
primearr[counter++] = i; //populate the array
//counter++; moved into above line
}
}
you can do a vector and grow it as you go, with push back, and preallocate it to your best guess. You can allocate a pointer to a run-time value size, but reallocating them is ugly. vector is the correct solution for unknown sized arrays, but you may not have seen them yet.