Here's one way, and you'll like it:
Make an integer array with the numbers that you want to randomly select from. Say I want random numbers 0-9, and each one never repeating.
Code:
array[10]={1,2,3,4,5,6,7,8,9,10};
now
//set srand() up before the loop
Use a for loop, from 1 to 7 (or so), get a random number in the range of 0 to 9
swap array[i] with array[random Number], in the usual way:
Code:
temp = array[i];
array[i]=array[random number];
array[random number]= temp;
and you're done.
You'll want to do at least 5 swaps, since you are moving two values, across an array of 10 values. To be more random, you may want to do 10 swaps, and do use a better random number design if you want REAL random performance. Generating truly good random numbers, is a lot more challenging than it looks. Thankfully, there are libraries that can help if that high a level of randomness, is needed. (doubtful, but just in case).