C Programming Code Examples C > Miscellaneous Code Examples C Program to Illustrate how User Authentication is Done C Program to Illustrate how User Authentication is Done This C program asks for the user name & password and displays the same to illustrate user authentication. - Take the user name & password as input. - Print the each character of password as * while receiving it. - Now print the original password and exit. #include <stdio.h> void main() { char password[20], username[20], ch; int j; printf("Enter User name: "); gets(username); printf("Enter the password < any 8 characters>: "); for (j = 0; j < 8; j++) { ch = getchar(); password[j] = ch; ch = '*' ; printf("%c", ch); } password[j] = '\0'; /* Original password can be printed, if needed */ printf("\n Your password is :"); for (j = 0; j < 8; j++) { printf("%c", password[j]); } }