mercredi 22 novembre 2017

How do I generate a unique 5 digit integer in C? [duplicate]

This question already has an answer here:

I need to generate a random 5 digit unique number. My code generates 20 random numbers but I need help getting only 5 digits.

The part of my code im having trouble with:

 int number[20];
 srand(time(NULL));
 int i=0;
 for(i=0; i<20; i++)
 {
   number[i]=rand();
 }




Aucun commentaire:

Enregistrer un commentaire