please i need your help to know how i should modify this code for being able to ask the user: the maximum number of numbers only he needs in the 12 characters_with_numbers password 2- the number of consecutive numbers in the 12 charachters_with_numbers password(for example if he enter 3, the password should not contain more than 3 numbers successively, but it can contains more than 3 they'll be placed in the password after a character between (at least).
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main() {
char password[12];
int i, j=0, len=sizeof(password)-1;
srand(time(NULL));
printf("Your Random Password is: ");
for (i = 0; i < 6; ++i)
password[j++] = 'a' + rand() % ('z' - 'a' + 1);
for (i = 0; i < 6; ++i)
password[j++] = 'A' + rand() % ('Z' - 'A' + 1);
for (i = 0; i < 3; ++i)
password[j++] = '0' + rand() % ('9' - '0' + 1);
password[j] = '\0';
for(i = 0; i < sizeof(password)-1; ++i)
{
char c = password[i];
j = rand() % len;
password[i] = password[j];
password[j] = c;
}
printf("%s\n\n", password);
system("pause");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire