• Advertisement
Sign in to follow this  

Password Input

This topic is 3870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way, in a dos prompt, to have a user's input be *****? For example, I ask a user to enter a password, instead of: Enter Password: my_password I want it to be: Enter Password: ********* I figure there is some sort of flag or member function for cin, but I can't seem to find reference to it anywhere. Thanks, James

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Hammonjj
I figure there is some sort of flag or member function for cin, but I can't seem to find reference to it anywhere.

You won't find anything standard/cross-platform on this, since cin only gets input after you enter whatever you typed (via return key). Header conio.h may have some stuff you want... but it's C (not C++) and non standard (DOS only, I think -- since that's what you are working on, then, seems to be fine).

Share this post


Link to post
Share on other sites

You just need to make a loop and keep track of what the user entered. I think the function is called kb_hit() or kbhit().. you use a while loop, and everytime the user enters a key you store it in a string, and output a '*'. If the user hits backspace, you remove a '*' and get rid of the last character in your string.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement