Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Password Generator

DZone's Guide to

Password Generator

·
Free Resource

#include
  
   
#include
   
    
#include
    
     
#include
     
      

int main() {

   int slump;
   int tal;
   int count = 0;
   time_t tid;

   slump = time(&tid);
   printf("Press CTRL-C to abort.\n\n");
   printf("Password: ");

   while (1) {
      srandom(slump);
      slump=random();
      tal= 1 + (int) (250.0*random() / (RAND_MAX+1.0) );
      if (((tal > 47) && (tal < 58)) ||
                         ((tal > 64) && (tal < 91)) ||
                         ((tal > 96) && (tal < 123))) {
         if (count < 8 ) {
            printf("%c", (char) tal);
            count++;
         } else {
            printf("\nPassword generated.");
            getchar();
            printf("\nPassword: ");
            count = 0;
         }
      }
   }
   return(0);
}


     
    
   
  
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}