home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GERLIB_DEV08B.LHA / gerlib / libg++ / etc / ADT-examples / genPatkey.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  691 b   |  36 lines

  1. #ifdef amiga
  2. #include <use_standard_argc_argv.h>
  3. #endif
  4.  
  5. // Generates random character strings
  6. #include <stream.h>
  7. #include <stdlib.h>
  8. #include <sys/types.h>
  9. #include <unistd.h>
  10.  
  11. main (int argc, char *argv[]) 
  12. {
  13.   if (argc != 3) 
  14.     {
  15.       cout << "usage: " << argv [0] << " number-of-keys length-of-keys\n";
  16.       return 1;
  17.     }
  18.   else
  19.     {
  20.       int Key_Number = atoi (argv [1]);     
  21.       int Key_Length = atoi (argv [2]);
  22.  
  23.       srand (getpid());
  24.  
  25.       for (int j = 0; j < Key_Number; j++)
  26.         {
  27.           for (int i = 0; i < Key_Length - (rand () % 20); i++) 
  28.             cout << char ('!' + rand () % (1+'~'-'!'));
  29.           cout << "\n";
  30.         }
  31.  
  32.       return 0;
  33.     }
  34.  
  35. }
  36.