I don't understand why you're having a problem getting random numbers that vary.
Just compile this code:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
srand(time(NULL));
int i;
for(i = 0; i < 10; i++)
{
printf("Random number %d: %d\n", i, rand() % 9); /* note this is 9 and not 8 because you're going from 0-8 which is 9 digits */
}
getch(); /* this is added so you can view your output */
}
My first result was:
Code:
Random number 0: 5
Random number 1: 3
Random number 2: 7
Random number 3: 1
Random number 4: 2
Random number 5: 0
Random number 6: 7
Random number 7: 6
Random number 8: 2
Random number 9: 5