In this program, without reading it any further, a nonsensical number of variables are declared.
It would be much better to use arrays or vectors here.
char Pone;
char Ptwo;
char Pthree;
char Pfour;
char Pfive;
char Psix;
char Pseven;
char Peight;
char One;
char Two;
char Three;
char Four;
char Five;
char Six;
char seven;
char Eight;
char Nine;
char Ten;
instead of Pone, Ptwo, Pthree, Pfour, Pfive, Psix, Pseven and Peight you could better write
char P[8];
or
vector<char>P(8, 0);
The Vector has several advantages; you can easily expand, delete and initialize elements.
In fact, all these variables are not even needed.
// EDIT:
Since both the name and the password are text, string would be the correct data type here. Rick had already explained to you that you can check or change each individual character of a string after it has been read. The current problem of the spaces disappearing would be gone if you read an entire line with getline(). Example: see my ChkPasswd() function below.
The password entry could be written much easier and better.
cin >> password;
for (auto &c:password) c = toupper(c);
if (password == "RANDOM") {
GenerateRandomPW(password);
}
else do {
cout << "Enter your Password, Make sure it's 8 characters long it has no tilde~\n";
} while (!ChkPasswd(password));
cout << "Your password is " << password << "\n";
The subprogram for checking the password could look like this:
bool ChkPasswd(string &password)
{
password.clear();
while (password == "")
getline(cin, password);
return true;
}
cout << "Enter your username, Make sure it's 10 characters long.";
cin >> One >> Two >> Three >> Four >> Five >> Six >> seven >> Eight >> Nine >> Ten;
bool c = isdigit(One);
bool ch = isdigit(Two);
bool che = isdigit(Three);
bool chec = isdigit(Four);
bool check = isdigit(Five);
bool checki = isdigit(Six);
bool checkin = isdigit(seven);
bool checking = isdigit(Eight);
bool checkingc = isdigit(Nine);
bool checkingch = isdigit(Ten);
cout << endl;
for (int i = 0; i < 100000; i++) {
if (c && ch && che && chec && check && checki && checkin && checking && checkingc && checkingch == 1) {
cout << "Username must contain a letter, pleae reenter your username ";
cin >> One >> Two >> Three >> Four >> Five >> Six >> seven >> Eight >> Nine >> Ten;
}
}
Entering a name is absolutely wrong this way. Not only are countless unnecessary variables consumed, but a whole host of other impractical restrictions are made.
1. Usernames should be 10 characters long and contain no spaces.
2. Checking whether letters are contained is nonsensical with the AND link
Only if all 10 variables contain digits would a new entry be made, but this is not checked.
3. There is no check for special characters or arithmetic symbols.
4. The for loop doesn't make sense because the index is never used and the loop repeats 1000000 times with the goes through the same immutable result. If the if() query is really going to be true, you have to Enter 100000 x 10 letters without changing the conditions.
The same as above applies to the many similar variables. They are all not needed here.
Solution for this:
Use strings for input and loop through the validation until the input is valid.
There are also other places that cause warnings that are better avoided.
The isdigit() function has an int return value. The assignment to a bool variable is ugly.
bool c = isdigit(One);
warning C4800: "int": Variable is set to Boolean value ("True" or "False") (impact on performance possible)
There is a problem with the string:
"@#',.$&^-_+={}[}()*?!%\/`<>";
warning C4129: "/": unrecognized sequence of escape sequence
The character '\' should be encoded differently here.