I am trying to generate 10 random numbers from 0-9, which goes well but I'd like them to each be unique, meaning for each one to only be used once.
How can I get this function to avoid repeats.Code:#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); char Array[10]; int i; for(i=0;i<10;i++) { sprintf(Array,"%d",rand()%9+1); printf("%s\n",Array); } return 0; }
I would just like to be pointed in the right direction..
Thank you in advance...