Question: I'm getting a warning C4018: '
I'm getting a warning C4018: '<': signed/unsigned mismatch in my code. Can someone help me fix it? this is a c++ password verfier code and I also need an end cout that tells the user that their password is accepted
#include
#include
#include
using namespace std;
const int PASSWORD_SIZE = 20;
//Function Prototype
int CheckPassword(char[]);
int main()
{
char password[PASSWORD_SIZE];
int length;
length = strlen(password);
while (1)
{
//Get the password.
do {
cout << "Please enter a password with at least 10 characters. ";
cout << "Enter your password: ";
cin.getline(password, PASSWORD_SIZE);
length = strlen(password);
} while (length < 10);
//Call function.
if (CheckPassword(password))
continue;
break;
}
system("pause");
return 0;
}
int CheckPassword(char pswd[])
{
int count;
bool upper_flag = 0, lower_flag = 0, digit_flag = 0;
for (count = 0; count < strlen(pswd); count++)
{
if (isupper(pswd[count]))
upper_flag = 1;
else if (islower(pswd[count]))
lower_flag = 1;
else if (isdigit(pswd[count]))
digit_flag = 1;
}
if (!upper_flag)
{
cout << "The password does not contain an uppercase letter. ";
}
if (!lower_flag)
{
cout << "The password does not contain a lowercase letter. ";
}
if (!digit_flag)
{
cout << "The password does not contain a digit. ";
}
if (upper_flag && lower_flag && digit_flag)
return 0; //if all pass
else
return 1;
}
and these were the instructions for this code
Implement the all the following as C++ programs for full credit. Submit only .cpp files only.
Imagine you are developing a software package that required users to enter their own passwords. You software requires that users passwords meet the follow criteria.
The password should be at least 10 characters long.
The password should contain at least one uppercase and at least one lowercase letter.
The password should have at least one digit.
Write a program that asks for a password and then verifies that it meets the criteria. If it doesnt, the program should display a message telling the user why it failed. It should not display all password criteria unless if failed all the criteria. If it failed only because the length was not 10 characters then it should inform the user of only that reason. For example, mypasswords fails to meet at least one upper case and does not contain a digit. If it fails to meet more than one criteria it should display all the reasons why it failed. The program should end when the user enters a valid password and display a message that password has been accepted.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
