#include <stdio.h> #include <string.h> #include <conio.h> #include <ctype.h> int main() { char buffer[256] = {0}; char password[] = "password"; char c; int pos = 0; printf("%s", "Enter password: "); do { c = getch(); if( isprint(c) ) { buffer[ pos++ ] = c; printf("%c", '*'); } else if( c == 8 && pos ) { buffer[ --pos ] = '\0'; printf("%s", "\b \b"); } } while( c != 13&& pos < 256 ); if( !strcmp(buffer, password) ) printf("\n%s\n", "Logged on succesfully!"); else printf("\n%s\n", "Incorrect login!"); return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)