programming-examples/c/Numerical/C Program to Generate N Number of Passwords of Length M Each.c

30 lines
721 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
/* Length of the password */
int length;
int num;
int temp;
printf("Enter the length of the password: ");
scanf("%d", &length);
printf("\nEnter the number of passwords you want: ");
scanf("%d", &num);
/* Seed number for rand() */
srand((unsigned int) time(0) + getpid());
while(num--)
{
temp = length;
printf("\n");
while(temp--)
{
putchar(rand() % 56 + 65);
srand(rand());
}
temp = length;
}
printf("\n");
return EXIT_SUCCESS;
}