I tried to generate infinite random number of range 0-9 using while loop, however my code only manage to generate 1 random number before exiting, why is it and how could I change it? Below is my code.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
while(1 < 2) {
srand(time(NULL));
printf("%d\n", rand() % 9);
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire