Machine Problem in C++

 Write a program to ask the user to give a password and the program will check if the password is right or not.  The program will hide the password using an asterisk character and the user can press the backspace for correction of the password. The program will repeat running itself if the given password is incorrect and exit when the right password is given by the user of the program.

  am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.

Program Listing

/* 

 Machine Problem in C++
 
 Write a program to ask the user to give a password
 and the program will check if the password is right or not.
 The program will hide the password using an asterisk character
 and the user can press the backspace for correction of the
 password. The program will repeat running itself if the 
 given password is incorrect and exit when the right password
 is given by the user of the program.
 
 password.cpp
 Mr. Jake Rodriguez Pomperada, MAED-IT,MIT
 www.jakerpomperada.com
 www.jakerpomperada.blogspot.com
 jakerpomperada@gmail.com
 Bacolod City, Negros Occidental Philippines
 
 */

#include <iostream>
#include <conio.h>
#include <string>

using namespace std;

const int PASSLEN = 4;

string passget();


void start()
	{

	string password;
	cout << "\n\n";
	cout << "\tLogin System With Asterisk in C++";
	cout << "\n\n";
	cout << "\tEnter Your Password: ";
	password = passget();

	if (password == "jake") {
	    cout << "\n\n";
	    cout << "\tPassword Accepted";
	    cout << "\n\n\n";
	    cout << "\t\t Thank You For Using this Software";

	}
	else {
	    cout << "\n\n";
	    cout << "\tPassword Denied Try Again !!!";
	    start();
	}
	}  // End of Start Function


int main()
{
    start();
	getch();
}

string passget()
{
	char password[PASSLEN], letter;
	int loop;
	int len;
	string password2;

		//Get Password and replace letters with *--------------
		loop = 0;
		while(loop != PASSLEN)
		{
			password[loop] = '\0';
			loop++;
		}
		loop = 0;
		len = 0;
		letter = '\0';
		while( letter != '\r' )
		{
			letter = getch();
			if( letter == '\b' && password[0] == '\0')
			{
				loop = 0;
				len = 0;
			}
			else
			{
				if( letter == '\b' && password[0] != '\0')
				{
					cout << "\b";
					cout << " ";
					cout << "\b";
					loop--;
					password[loop] = '\0';
					len--;
				}
				else
				{
					if( isprint( letter ) != 0 && loop < PASSLEN)
					{
						password[loop] = tolower(letter);
						cout << "*" ;
					}
					loop++;
					if (loop <= PASSLEN)
						len++;
				}
			}
		}

		//Convert Password from character array to string
		loop = 0;
		len = len;
		password2 = "";
		while (loop != len)
		{
		password2 = password2+password[loop];
		loop++;
		}

	return password2;
 } // End of Function Password