0

how to make a simple password lock in c++??

i want a alphabetic lock

btw thanks for helping

4
Contributors
7
Replies
11
Views
7 Years
Discussion Span
Last Post by ylin333
0

Can you please clarify? You want to have a prompt such as :

"Enter the password: "

and then check if the password that is entered is correct? Depending on the security level needed, you could just hardcode the password in the code and do a string comparison. Another common feature would be to "mask" the password that is entered (with *'s perhaps), but I don't know how to go about that.

Dave

0

i want to have a prompt such as :


"Enter the password: "

0

I think it's inpossible to replace typed letters/numbers with a '*' in c++, however you could get keyboard input directly with kb_hit(). To use the function kb_hit() you need to have the C header 'conio.h'.

#include <conio.h>

For example;

char example[10]
if (kb_hit()==TRUE) {
example=getchar();
}

Edited by ylin333: Explanation

0

If you use kb_hit(), and system('cls') you will be able to clear the typed characters straight away so that they do not appear. By the way, I think using a character array like that doesn't work, so sorry.

0

No problem. I'm not entirely confident about that code since it has been a while I used a function of that type. If there are any problems feel free to ask me or you can Google it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.