I'm trying to make lotto program.
and when this program generate numbers in between 1 and 40.
they display -858993460 7 times
I don;t know what's wrong with my code
void* genWinNum(int getNum[])
{
constint MAX_NUM = 40;
constint MIN_NUM = 1;
constint NUM = 7;
int num[NUM];
int* nums = num;
srand(time(NULL));
for(int i = 0; i < NUM; i++)
{
num[i] = (rand() % 40) + 1;// generate random number 1 to 40
while(num[i] < 1 || num[i] > 40)// more than 40 and less than 1 is false
{
num[i] = (rand() % 10) + 1;// generate random number again till getting number between 1 to 40
}
if(i > 0)
{
for(int index = 0; index < i; index++)
{
while(num[i] == num[index])//generate number not to duplicate
{
num[i] = (rand() % 10) + 1;
}
}
}
}
return nums;
}