Brother, i am tried with these codes. But it works. But the issue is when i pressed the backspace key on my keboard it also taken as a password input. Does any one can fix this??
Your problem is you're adding the backspace character, '\b', to the password string. In addition to your check for the enter key (which should be rewritten (ch != '\r'), so you wouldn't need the comment about it), you should check if they enter '\b' then pull the next most recent char out manually.