In fillArray() you have created a local array (automatic variable) on the stack heap, pretending to give it back as result. This is
wrong when the function returns the stack is reused by next functions and
filled with their automatic data that for you are garbage!
If you need an array to give back create it with the new operator, or allocate it from malloc.
Other observation: take care of compiler warnings, you should have had some, because not all paths of your function return a value!
This is the correct coding for fillArray().
And don't forget to free memory (using Delete) when finished with the array.
int* fillArray(int size, int lowerBound, int upperBound){
int counter_repeat;
int loopcount = 0;
int repeat =0;
int random;
int receive;
int setrand;
int *pholdArray= new int[size];
if(checkDuplicate(size,random,pholdArray) == 3);
counter_repeat++;
for(int i =0;i<size;i++){>
random = randomNum(lowerBound,upperBound);
if(checkDuplicate(size,random,pholdArray) == 3){
counter_repeat++;
while(checkDuplicate(size,random,pholdArray) == 3){
random = randomNum(lowerBound,upperBound);
counter_repeat++;
}
}
pholdArray[i] = random;
if(i == size-1){
return pholdArray;
}
}
return pholdArray;
}