#include<stdio.h>
void main()
{
char pwd[20]="Oracle"; // your password.
char ent_pwd[20]; // The typed password will be stored in this array.
char ch;
int i=0; // used refer array index.
printf("Enter the password : ");
while( (ch=getch()) !='\r' ) // getch() is used to read the char soon after pressing the key.
{
ent_pwd[i++]=ch;
printf("*"); // '*' is echoed for each keypress
}
ent_pwd[i]='\0'; // assign null char to string( user entered password ).
if( strcmp(pwd,ent_pwd)==0 ) // if password matched
printf("\nLogin success full");
else
printf("\nLogin failed");
getch(); // here getch() is used to go to user screen.( general use of getch() )
}
Note : getch() is unformatted unbuffered character input function,unbuffered means the char typed will read readily without waiting for enter key to be pressed.