C Programming Code Examples C > Miscellaneous Code Examples Program to Input Password for Validation of User name Program to Input Password for Validation of User name How to Input Password in C ? 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. [j] Store Accepted Character in String array . Instead of Displaying Character , display Asterisk (*) #include<stdio.h> #include<conio.h> void main() { char password[23], ch; int j; clrscr(); puts("Enter password : "); while (1) { if (j < 0) { j = 0; } ch = getch(); if (ch == 13) break; if (ch == 8) /*ASCII value of BACKSPACE*/ { putch('b'); putch(NULL); putch('b'); j--; continue; } password[j++] = ch; ch = '*'; putch(ch); } password[j] = '\0'; printf("\nPassword Entered : %s", password); getch(); }