Generating lottery numbers

This is a discussion on Generating lottery numbers within the C++ Programming forums, part of the General Programming Boards category; Hello Everybody.
I have another problem that I do not know how to solve. Here is the problem:
Write a ...

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:

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.

The input parameter is ( int lotteryNumbers[] ), I was trying to get the validation of the generated numbers figured out. As for not using the input parameter, I am not sure how to write that, I am having trouble understanding arrays, and passing them back and forth between functions.

If you don't get your mind wrapped around the data types you are using then you are going to have a real had time getting the programs to behave like you want them to do. There is no shame in making a simpler program first and once it works adding to it. You said you have a problem telling if a number is already in an array you could write a shorter program to just achieve that task. Once it is finished then you can add another level of functionality.

Some of the programs I've done have neared 15k lines of code which become really fun to manage coding on your own. If I didn't test each function seperately before throwing the into the big program I would have crashes every other day. Its alot easier to track an error in 10 lines of code than it is to find in 10k lines of code.

As for your code itself look back at your do while loop and the value of used. If you find a matching number in the array one time you will get lost in that loop forever.

Suggestions - yes. Close the IDE/text editor, take out a pen and paper, and try to develop an algorithm by hand. When you get an idea of how to solve the problem, this will help you structure your code accordingly. This is preferable to asking "how do I do this?" in a forum each time you get stuck. I'm not trying to be rude - this is genuine advice that will help improve your programming skills.

As to suggestions for your particular question (checking for duplicates):

There are a few ways to go about this. As a beginner, it would be best if you took a "one step at a time" approach - the algorithm won't be as efficient as it could be, but it will work when done right. Here is a suggested algorithm for you to review:

Step 1: Fill the array with random numbers
Step 2: Sort the array (bubble sort is a common sorting algorithm that I find beginner-friendly)
Step 3: Check for duplicates - now that the array has been sorted, checking for duplicates is straightforward. Basically, if value[i] == value[i+1], then you have a duplicate. If you use this method, be sure to structure your loop terminating condition carefully so you don't overrun your array! (Hint: look at the 'i+1')
Step 4: If a duplicate is found, generate a new random number for that position

I don't mean to be a pain but I am in a first year class and we haven't covered how to sort an array or anything else for that matter. You seem to have a great deal of knowledge on this that I haven"t been exposed to yet. Your patience would be greatly appreciated.