|
| Default (9) | |
| Hi! I am making a program that keeps things like passwords. I wanna make a password to access this program. But i have a question: how change password letters into '*' thanks for help! | |
| jsmith (3099) | |
| You must turn off character echoing when you read the user's input and, for each character input, you'll need to output an "*" instead. Of course then you need to handle specially the backspace key, left/right arrows, home/end, etc. The actual implementation depends on your OS. For DOS getch() or getche() (I can't remember which) does the trick. For Un*x you have to turn off terminal echoing on stdin via termios settings. | |
| ponki d monkey (23) | |
You can use something like character=getch();. It will get the value of the character that you type, but it will not display it. Then you can just use conditional statements to display an "*". And as mentioned above, you need to set the backspace key, left/right arrows, home/end, etc. manually... | |
| Default (9) | |
| Thanks! (I made it :-)) | |
| CheesyBeefy (80) | |
| Sorry, I'm having the same problem, but I don't understand your answer. (I'm fairly new to C++) My program takes your created password and saves it to a text document, but I don't want the password to be seen while it is being typed in. (*'s to replace characters.) Could you please provide an example? I am using Windows with VC++ 2008 Express Edition. Thanks in advance, CheesyBeefy | |
| jsmith (3099) | |
| If you read the user's input with getch(), the characters entered are not automatically echoed to the screen. So if you use this function, then any time the user enters a character, you can cout << '*' << flush to print an asterisk instead. However, you will have to write special code to handle keypresses such as Backspace, home/end, left/right arrows, and enter. | |
This topic is archived - New replies not allowed.
