Can someone help me with c++

Feb 19, 2017 at 9:03pm
Recently I decided to make a complex pass generator, I finished that and decided to make it output to a file, this is where things get hairy, im trying to output the password to the text document. I would appreciate the help thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  #include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <Windows.h>
#include <fstream>
using namespace std;

static const char alphanum[] =
"0123456789"
"!@#$%^&*"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
int size = sizeof(alphanum) - 1;

int main()

{
int length;
ofstream outputFile;
outputFile.open("Password.dat");
outputFile << "Your password is:";

	//password length
	cout << "Please enter the amount of characters you want your password to be" <<endl;
	cin >> length;
	cout << "Your password is" <<endl;
	srand(time(0));
	for (int password = 0; password < length; password++)
	{
		cout << alphanum[rand() % size];
	}
	outputFile << " " << THIS IS WHERE I NEED HELP << " " << "characters" <<endl;
	outputFile.close();
	Sleep(99999999999999);
	return 0;
}
Feb 20, 2017 at 12:18am
you have to store it if you want to use it. You were generating it and printing then discarding it.

char pwd[1000] = {0};

for (int password = 0; password < length; password++)
{
pwd[password] = alphanum[rand() % size];
cout << pwd[password;
}

outputfile << pwd
Feb 25, 2017 at 4:25am
Thank you so so so very much you helped me tons.

Would there be a way to make it not overwrite the current pass?
-Garrows
Topic archived. No new replies allowed.