When I put while (valid = true) the loop prompts me to input Pass but then the program does nothing. When I put while (valid = false) the program doesn't prompt for the input and immediately ends. How do I get this loop to execute properly? It is a bit confusing when a loop contains this many if statements.
#include <iostream>
#include <string>
usingnamespace std;
void testLength(int Pass[], int valid);
void testCaps(int Pass[], int valid);
void testNum(int Pass[], int valid);
int main()
{
int Pass, valid;
while (valid = true)
{
cout << "Please enter a password:";
cin >> Pass;
int Pass[sizeof(Pass)];
testLength(Pass, valid);
if (valid = true)
{
testCaps(Pass, valid);
if (valid = true)
{
testNum(Pass, valid);
if (valid = true)
{
}
else
{
cout << "Passwords must include at least one number" << endl;
}
}
else
{
cout << "Passwords must include at least one uppercase letter" << endl;
}
}
else
{
cout << "Passwords must be at least 7 characters long" << endl;
}
if (valid = true) break;
}
cout << "Thank you, that is a valid password" << endl;
return 0;
}
void testLength(int Pass[], int valid)
{
if (sizeof(Pass) >= 7)
{
valid = true;
}
else valid = false;
returnvoid(valid);
}
void testCaps(int Pass[], int valid)
{
valid = 0;
int i = 0;
while (i < sizeof(Pass))
{
if (Pass[i] >= 'A' && Pass[i] <= 'Z')
{
valid = true;
}
}
i = i + 1;
returnvoid(valid);
}
void testNum(int Pass[], int valid)
{
valid = 0;
int i = 0;
while (i < sizeof(Pass) - 1)
{
if (Pass[i] >= '0' && Pass[i] <= '9')
{
valid = true;
}
}
i = i + 1;
returnvoid(valid);
}