#include#include#include#include// Function to generate a random string of specified length containing only alphanumeric charactersvoidgenerateUsername(char*str,int length){constchar charset[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";// Characters to choose fromint charsetLen =strlen(charset);for(int i =0; i < length;++i){int index =rand()% charsetLen;
str[i]= charset[index];}
str[length]='\0';}// Function to generate a strong password with special charactersvoidgeneratePassword(char*str,int length){constchar charset[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[]{};:'\",.<>/?";// Characters to choose from including special charactersint charsetLen =strlen(charset);for(int i =0; i < length;++i){int index =rand()% charsetLen;
str[i]= charset[index];}
str[length]='\0';}intmain(){char username[9];// Change the size as per requirement for 8 characters + null terminatorchar password[13];// Change the size as per requirement for 12 characters + null terminatorsrand(time(NULL));// Seed for randomization based on current time// Generate usernameprintf("Generating Username...\n");generateUsername(username,8);// Generates an 8-character username using only alphanumeric charactersprintf("Generated Username: %s\n", username);// Generate passwordprintf("\nGenerating Password...\n");generatePassword(password,12);// Generates a 12-character password including special charactersprintf("Generated Password: %s\n", password);return0;}