I have a slight problem in finishing my code. My task is to create a program that creates a randomly generated array of size 10, with any number between 1-50. All of these numbers must be unique. The user is asked to input a number, and then the program should decipher wether the users input matches any of the randomly generated numbers within the array. I cannot use any fancy functions that come from a library, I must construct my own. Here is my code so far. I am having trouble using the check function inside of main. I am not sure if this is just because of my lack of knowledge (probably) or if I just can't do it when the parameter is an array. Any help is appreciated.
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <iostream>
using std::cin; using std::cout; using std::endl;
int check(int fillFunc[]){
while(true){
int val = 1 + rand() % 50; //assume it's unique
bool unique = true;
for (int i = 0; i < 10; ++i){ //if another number matches, it isn't unique, choose again
if (fillFunc[i] == val){
unique = false;
break;
}
}
//if it is unique, return it.
if (unique){
return val;
}
}
}
void draw(int fillFunc[]){
for (int i = 0; i < 10; i++){
fillFunc[i] = check(fillFunc);
}
}
void printOut(int fillFunc[]){
for (int i = 0; i < 10; i++){
cout << " " << fillFunc[i];
}
cout << "\n";
}
int main(){
srand((unsigned)time(NULL));
const int arraySize = 10;
int win[arraySize] = {};
cout << "Please enter a number: ";
int guess;
cin >> guess;
cout << "\n";
draw(win);
cout << "Congrats! Your number matches one from the lottery!";
cout << "Your lottery numbers are: ";
printOut(win);
cout << "\n";
}