Generating lottery numbers

Hello Everybody.

I have another problem that I do not know how to solve. Here is the problem:

Write a function named generateLotteryNumbers. The function is passed an int array of size 5. The function should generate **5 different** lottery numbers in the range 1 to 50 inclusive and place the numbers in the array. The declaration is as follows:

void generateLotteryNumbers (int lotteryNumbers []);

Note that no data is passed in to the function. The array is used to return the function results. Thus the parameter is an OUT parameter. Do not display the result. Return the result.

Do not seed the random number generator inside the function. If you seed the random number generator inside the function and the function is called many times in the same second, your function will return the same results each time it is called.

I know how to generate the numbers in the specified range but I do not know how to test for duplicates. Here is the code I have so far:

Code:

`//This program will test the "generateLotteryNumbers" function`

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

void generateLotteryNumbers (int lotteryNumbers[]);

void main()

{

int lotteryNumbers[5];

srand (time(0));

generateLotteryNumbers (lotteryNumbers);

cout << lotteryNumbers << endl;

}

//This function will generate five lottery numbers

#include <iostream>

using namespace std;

void generateLotteryNumbers (int lotteryNumbers[])

{

const int SIZE = 5;

int randomNumbers;

int index = 0;

int number;

bool used;

for (int index = 0; index < SIZE; index++)

{

int number = rand()% 50 + 1;

do

{

used = false;

for(int index = 0; index < SIZE; index++)

{

if( number == randomNumbers[index] )

used = true;

}

}while(used);

randomNumbers[index] = number;

}

}

when I try to compile this, my compiler tells me that lines 41 and 46 require an array or pointer type.

I have no idea what that means and my instructor will not tell me. He just says that there is something wrong.

validating the generated numbers

I now have the generator working,the next problem is to validate the numbers generated to insure there are no duplications. Here is the generator code that works:

Code:

`void generateLotteryNumbers(int lotteryNumbers[])`

{

const int arraySize = 5;

int index = 0;

while (index < arraySize)

{

lotteryNumbers[index] = rand() % 50 + 1;

cout << lotteryNumbers[index] << endl;

index++;

}

}

Can someone please help me with this.