I am using an array in C++, trying to generate a random number that isn't in a list of numbers used before (so each number is in a set range, can only appear once, but is in a random order) However on running it says that there is no begin function (code snippet attached)
int GenRandIndex(int size, int used[]){
bool ret=false;
int n;
while (!ret){
n=GenRandNum(0,size-1);
for (int i:used){
if (n==i){
break;
}
else{
ret=true;
}
}
}
return n;
}
int c[4]={0,2,3,4};
cout << GenRandIndex(5,c);
This should (in theory) output 1, as it should generate a random number between 0 and 5-1 (4), and keep generating until it reaches a number that isn't in the list c (of which the only choice is 1) however I get the error in the title (error C2672: 'begin': no matching overloaded function found)