#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int randint(void);
int main(void) {
for (int i = 0; i < 10; i++) {
printf("%d ", randint());
}
return 0;
}
int randint(void) {
srand((unsigned)time(NULL));
return rand() % 81 + 10;
}
My intention is to print 10 different numbers. However, 10 duplicate numbers are printed continuously each time. How can I resolve this issue?
I used library functions like the srand()
function. And I changed the position of the function little by little, but the result was the same.
Expected 84 40 35 60 45 84 40 77 37 11
Output 11 11 11 11 11 11 11 11 11 11