HELP!! Randomly assigning passwords

I,m trying to create a code that takes to .txt files with names and passwords to create usernames and then randomly assign them passwords. I keep getting errors but I can not find what I am doing wrong

#include<iostream> //basic input and output
#include<fstream> //to read and write files
#include<string> //to handle string data
#include<time.h> //randomization
#include <random>
#include <ctime>
#include <algorithm> // std::shuffle
int i = 0;

int main()
{
std::ifstream inputFile;
std::string firstName; //stores the first name
std::string lastName; //store the last name
std::ifstream inputHandler; //file handler to work with the input text file
std::ofstream outputHandler; //file handler to work with the output file
inputFile >> firstName >> lastName;
inputFile.open("names.txt");
std::string Users[50];
std::string passwords[50];


if (!inputHandler)
{
std::cout << "Invalid input file. Program terminated." << std::endl;
}

else
{
outputHandler.open("userPasswords.txt");
inputHandler >> firstName >> lastName;
while (!inputHandler.eof())
{

outputHandler << "<userName>" << firstName[0] + lastName.substr(0, 7) << "</username>\n";
inputHandler >> firstName >> lastName;

}
inputHandler.close();
}
std::ifstream file("names.txt");
if (file.is_open())
{
std::string Users[50];
for (int i = 0; i < 50; ++i)
{
file >> Users[i];
std::cout << Users[i] << std::endl;
}
}
std::ifstream fileX("passwords.txt");
if (fileX.is_open())
{
std::string passwords[50];
for (int i = 0; i < 50; ++i)
{
fileX >> passwords[i];
std::cout << passwords[i] << std::endl;
}
}
constexpr std::size_t N = 5; // 50
std::string user_name[N] = { "Twentyone", "Twentytwo", "Twentythree", "Twentyfour", "Twentyfive" };
std::string password[N] = { "one", "two", "three", "four", "five" };
std::shuffle(password, password + N, std::mt19937(std::time(nullptr)));
for (std::size_t i = 0; i < N; ++i) std::cout << user_name[i] << " : " << password[i] << '\n';
return 0;
}



#include<iostream>
#include <time.h> //needed to use randomization

int main()
{
int randomNumber;

//Initialize seeding for random numbers
srand(time(NULL));

//Print out a set of 10 random numbers between 0 and 19
for (int x = 0; x < 10; x++)
{
//Generate a random number between 0 and 19
randomNumber = rand() % 20;

std::cout << "Random number " << x + 1 << " " << randomNumber << std::endl;
}

return 0;
}
Topic archived. No new replies allowed.