Hm, afaik there is no easy way of doing this. I once was messing around with some code, and it stopped a user inputting a wrong character type (so the user couldn't type a char into an int or vice versa). That interacted with the TTY layer (on a linux box)..
I don't think it is all that hard. Try something like this.
#define backSpace 8
#define newLine 13
// you can make it better by passing the length of the password
// and testing for the length as well as newLine.
int GetPassword(char *str);
int GetPassword(char *str)
int i = 0,end = 0;
if (i > 0)
*str = '\0';
end = 1;
*str = ch;
There is a simple way to do this. Initialize a character a and write a=getch(). This would not display the character entered by the user.
a=getch(); // varable a will have the character entered by the user.The character
cout<<'*'; // entered by the user will not be displayed. cout<<'*' will put '*'
//appearing to the user that character that he entered was masked
Instead of a character, declare varable a as a character array. Put that in for loop(a=getch etc.,). The password that the user enters is masked now.Though getch() is not in ANSI c standard it will work.