Hidden Password
This code allows the user to imput a password (within a C++ program) without any text being displayed on-screen (not even *'s)
AI
Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Codice sorgente
#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)
Commenti originali (3)
Recuperato da Wayback Machine