The line "getline(cin,get_password);" doesn't repeat if the user chooses to re-enter the password. It pauses for a short while when it should run that line, refuses to accept any data, and then continues as normal.
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main()
{
string get_password;
string password="abc4";
char repeat1;
char repeat;
do
{
cout<<"Please enter the password"<<endl;//The password is abc4
getline(cin,get_password);
do
{
cout<<"Password length check...";
Sleep(1000);
if(get_password.length()==password.length())
{
cout<<"Completed"<<endl;
Sleep(500);
}
else
{
cout<<"Incorrect password"<<endl;
}
}
while(repeat1=='Y'||repeat1=='y');
if(get_password==password)
{
cout<<"The password is correct."<<endl;
repeat='n';
}
else
{
cout<<"The password is incorrect."<<endl;
cout<<"Do you want to re-enter the password?\tY/N"<<endl;
cin>>repeat;
}
}
while(repeat=='Y'||repeat=='y');
return 0;
}