| ACE123 (13) | |||
|
Hi, my program requires a username and password to gain access. I need to mask the password input with *. I have researched heaps and found codes that don't work for what I want. After the user enters the password, it is checked against a password already stored. the password is string 'alpha'. Below is the login section of the program.Any help would be fantastic. Thanks
| |||
|
|
|||
| Riper97 (16) | |||
|
I don't know if this is what u exactly wanted What this does is... It has 2 strings beta&Alpha and it opens the login where it asks u for a username and password... Once u type the username and password... it checks if the username typed is Guest and if the password is Guest.. if(beta != "Guest" || alpha != "Guest") so what this says is if Username is not Guest And Password is not Guest return 1 aka exit else ... so what the else means here is If both are correct it will proceed :) You could also store the usernames and passwords in a text file and read them, but anyone can find the text file and change it and gain access :)
| |||
|
Last edited on
|
|||
| Moschops (5961) | |
|
There is no one way to hide what the user is typing; C++ has no knowledge of what a keyboard or a screen is. That sort of thing is handled by your operating system, so you need to use libraries beyond the C++ standard. Using Windows? | |
|
|
|
| Riper97 (16) | |||
|
You can actually :) I got confused in his question and thought that he didn't knew how to check if password is correct or wrong :) but tnx to Moschops i see that he wants to type and * show up on screen but the program would still know what u typed :) Here you go ... try this piece of code :) This program will let u type a password and then when u press enter it will tell you what you typed :)
| |||
|
|
|||
| Moschops (5961) | |
Note that this solution relies on the non-standard conio.h
| |
|
|
|
| Riper97 (16) | |
|
I was expecting u :) Yes it does and you are right :) I learnt C++ on my own and the problem is that i skipped some parts and i have been in a situation where people asked me something and idk what that is but i only don't know the names of the functions :) Btw i am working on a game and i'm stuck at the map a little i could use some help if anyone is interested :) | |
|
|
|
| cppbeginer123 (9) | |
|
http://www.pasteall.org/32479 This work for me . | |
|
|
|
| ACE123 (13) | |
|
Thanks for all your replies. but something still doesn't work. these codes store the password as a char and therefore I can't test it against my string. I need to convert the char into a string. if you need the rest of the code, please ask. Josh | |
|
|
|