//Create a random 10 character password with the first character being a upper case letter. The remaining characters are random selections of Upper case
//letters, lower case letters, 9 digits and/or special characters (found only on the top row of your keyboard). Please exclude 0 and O's from being used.After generating the password, display the password to the user and ask them to enter the password until it is entered correctly. Once the password is entered correctly please display the message "Sign On now successful!".
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
static const char alphanum[]= "123456789"
"!@#$%^&*"
"ABCDEFGHIJKLMNPQRSTUVWXYZ"
"abcdefghijklmnpqrstuvwxyz";
int size = sizeof(alphanum) - 1;
char password=alphanum[rand() % size];
int main()
{
//password size
int length = 3;
cout << "Your Password is ";
srand(time(0));
for (int i = 0; i < length; i++)
{
cout << alphanum[rand() % size];
}
{
cout << endl;
}
{
cout << "enter the provided password " << endl;
cin >> password;
if ((password = alphanum[rand() % size]))
cout << "works" << endl;
}
return 0;
}
emilio_3
0
Newbie Poster
Recommended Answers
Jump to PostI would encourage you to fill a buffer with the user's password first, then display it - and in that local buffer you can do a strcmp.
Just my preferred way of solving your problem.
Otherwise... you have uncompleted code here.. not sure what part of it you need help …
Jump to PostHow do you expect to compare what the user has entered if you don't keep reference to the password you generated?
I stand by my original comment: start by filling a buffer with your created password, then use that to both output the password as well as compare it to …
Jump to PostLine 40 has another issue. I see a single equal sign. Do you know why that matters?
This is beyone what ryantroop is commenting about.
All 11 Replies
ryantroop
177
Practically a Master Poster
emilio_3
0
Newbie Poster
ryantroop
177
Practically a Master Poster
emilio_3
0
Newbie Poster
rproffitt
2,580
"Nothing to see here."
Moderator
ryantroop
177
Practically a Master Poster
emilio_3
0
Newbie Poster
emilio_3
0
Newbie Poster
emilio_3
0
Newbie Poster
emilio_3
0
Newbie Poster
ryantroop
177
Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.