If you are working on windows system,use getch() to not display the character and cout<<"*";
Since there is no getch() in UNIX,try turning off the echo attribute of the console by using system("stty -echo"), then reading the input a character at a time, and reenabling the echo afterwards.
Also try using getpass() function which leaves its result in an internal static object and returns a pointer to that object