It's best to include the #include stuff as long as its standard library headers, as it makes it easier for others to quickly run your code to help you.
A self-contained check-for-spaces function would look like this:
1 2 3 4 5 6 7 8 9
bool has_spaces(string s)
{
for (int i = 0; i < s.size(); i++)
{
if (s[i] == ' ')
returntrue;
}
returnfalse;
}
__________________
Something else to add: The way I would go about this problem is to have something like this:
(pseudo code)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ask user to input password
do
{
int error_code = password_test(password);
if (error_code) {
print error_message[error_code];
ask for password entry again
}
else {
password is acceptable
}
} while (not good password);
If that doesn't make sense, don't worry about it, it's just suggestion.