I am completely lost within the function I have to make a program that has at least 7 to 8 characters on lower case , one upper case and one number can someone help me?
#include <iostream>
#include <cstring>
usingnamespace std;
intconst MAX = 10;
int valid(char*);
int main ()
{
char pword[MAX];
bool result;
cout <<"Password:";
cin >> pword;
valid(pword);
result = valid(pword);
if (result == true)
cout <<"Valid password!!\n";
else
cout <<"Wrong password\n";
return 0;
}
int valid(char* word)
{
int score = 0;
int score2 = 0;
if (strlen(word) < 8)
cout <<"Sorry not enough";
for (int x = 0; x < MAX; x++)
{
if(isdigit(word != 0))
score++;
if(isupper(word != 0))
score2++;
}
if (score > 0 && score2 > 0)
returntrue;
} Put the code you need help with here.
int valid(char* word)
{
int score = 0;
int score2 = 0;
int len = strlen(word); // Note
if (len < 8)
cout <<"Sorry not enough";
elsefor (int x = 0; x < len; x++) // Note: Use len instead of MAX
{
if(isdigit(word[x]) != 0) // Note
score++;
if(isupper(word[x] != 0) // Note
score2++;
}
if (score > 0 && score2 > 0)
returntrue;
returnfalse; // Note
}