Can anyone spot the error in my code? The program will enter the last while loop but continue in an infinite loop... I figured fresh eyes may help spot the flaw!
int xlist[1500], ylist[1500], counter = 0, tempx, tempy, tempcounter;
bool assign = false;
while(counter < 1500)
{
xlist[counter] = -1;
counter++;
}
counter = 0;
while(counter < 1500)
{
ylist[counter] = -1;
counter++;
}
counter = 0;
while(counter < 1500)
{
tempx = (rand() % 500);
tempy = (rand() % 500);
while(tempcounter < counter)
{
if(xlist[tempcounter] != tempx || ylist[tempcounter] != tempy)
{
assign = true;
tempcounter++;
}
else
{
tempcounter = 0;
assign = false;
break;
}
}
tempcounter = 0;
if(assign)
{
xlist[counter] = tempx;
ylist[counter] = tempy;
counter++;
}
}