home *** CD-ROM | disk | FTP | other *** search
- /* A rather trivial program to generate a random password for CBBS
- using the integers from 1 to 99
- Pete VE5VA
- */
- int vector[100];
- long dates[3];
- main(argc,argv)
- int argc;
- char *argv[];
- {
-
- register int j,k,l;
-
- DateStamp((struct DateStamp *)&dates[0]);
- srand((short)((dates[0]*50 + dates[2]) | 1));
- /* j counts the 64 numbers. 'l' is used to limit the number of times
- around the loop because rand() is not a super efficient generator
- of random numbers and can itself go into a loop.
- */
- for(j=0,l=0;(j < 64) && (l<2000);l++) {
- k = rand()%99 + 1;
- if(vector[k])continue;
- vector[k] = 1;
- printf("%3d",k);
- j++;
- if((j % 10) == 0)printf("\n");
- }
- printf("\n");
- if(l >= 2000) {
- printf("rand must have looped - try again\n");
- }
- }
-