VB icon

Hidden Password

Email
Submitted on: 1/3/2015 5:11:00 PM
By: Mike Richards (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: C++ (general), Microsoft Visual C++
Views: 963
 
     This code allows the user to imput a password (within a C++ program) without any text being displayed on-screen (not even *'s)
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :Hidden Password
//**************************************
#include <conio.h>
#include <iostream.h>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Hidden Password
// Description:This code allows the user to imput a password (within a C++ program) without any text being displayed on-screen (not even *'s)
// By: Mike Richards (from psc cd)
//
// Inputs:user imputs the characters in the password
//
// Returns:password returns true if password was correctly imput, and false if the password was not
//
// Assumes:getch() allows for real-time imput w/out having to type enter. useful in games and a variety of other applications
//
// Side Effects:no that i know of
//**************************************

#include <iostream.h>
#include <conio.h>
bool passcheck(void) //checks password WITHOUT displaying the characters on-screen
{
	char password[7] = "outlaw"; //[] can be used instead, but it takes more memory, its quicker than counting though
	int plen = 6; //plen must be the number of letters in password
	char let;
	for(int i = 0; i < plen; i++)
	{
		let = getch();
		if(password[i] != let)
			return false;
	}
	return true;
}
//the above code immediately returns false if an incorrect password is imput
//if you want it to only return false at the end of the password, create a seperate bool variable
//to be returned at the end of the program
//instead of a for statement you can use (while x != 13) and hit enter at the end of the password
//(13 is the ascii value of enter)


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.