C Program to Input Password for Validation of User name


How to Input Password in C ?

Output :


Explain ?

  • Accept Character without Echo [ without displaying on Screen ]
  • getch will accept character and store it in “ch”

  • ASCII Value of “Enter Key” is 13
  • Stop Accepting Password Characters after “Enter” Key.

  • ASCII Value of “BACKSPACE” is 8
  • After hitting “backspace”following actions should be carried out –
    • Cursor Should be moved 1 character back.
    • Overwrite that character by “NULL”.
    • After Writing NULL again cursor is moved 1 character ahead so again move cursor 1 character back .
    • Decrement Current Track of Character. [i]

  • Store Accepted Character in String array .
  • Instead of Displaying Character , display Asterisk (*)