Hello Im coding a very basic password generator and I want to write the output of the loop to a file using ofstream. My idea was each time the loop runs output one vocal from the array abc
. I don't know to to make it to work and obvs. there is a better way of doing it.
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <fstream>
using namespace std;
int main(){
srand(time(0));
cout << "You'r PW is: \t" << endl;
char abc [] {'A', 'a', 'B' ,'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'V', 'v', 'W', 'x', 'Y', 'y', 'Z', 'z'};
for(int i = 0; i <15; i++){
int randomNum = rand() % 53;
cout << abc[randomNum];
ofstream fob;
fob.open("contr.txt");
fob << abc[randomNum];
}
}
By the way, I am getting characters like ',' and '->' which isn't in my array.