How to hide what a user has entered with *'s

This is a discussion on How to hide what a user has entered with *'s within the C++ Programming forums, part of the General Programming Boards category; Hi,
Im pretty new to programming, and couldnt find how to do this anywhere.
Im looking for some code so ...

That while loop is kinda condensed, but you could break it up if you wanted to.

edit: This is very basic. You'd probably want to do lots of testing to see if someone hit backspace etc, and if you do that here it'll keep on adding *'s regardless. If you want to get a number out of this you should use stringstreams to accomplish it.

Salem, thanks for the help. I can now not put in a 5 or more digit number, if I do, the loop will run and not stop giving chance to enter a new number. Also, if I enter a 4 digit number, then another 4 digit number that is the same, and check that the second number that the user enters is the same as the first number, it will say that they do not match, whereas it didnt when using 'int'. The same happens with 3, 2 or 1 digit numbers. Please could you see if anything is wrong within this code?

twomers, thank you also, I get the basic idea how to acomplish this now. I tried to run the code you had, but the compiler gave an error with 'VK_RETURN' as it has not been declared as a variable. Am I supposed to replace this with something?

Help apreciated, thanks.

EDIT:

I have declared 'VK_RETURN' as an int variable, and it works fine, apart from when I press return, it just comes up with an additional star, any ideas? Thanks.

The digit count was working fine after messing around with some code, I then added in the hide function which worked fine, but this stopped it from being able to detect when passwords are MORE that 4 digits, LESS than 4 digits still works, apart from zero digits. Any ideas? Here is the code i've got at the moment.