Created
July 5, 2016 10:36
-
-
Save Mashpy/08d9bb1acfe7ebd3787078be109cba48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <conio.h> | |
#include <ctype.h> | |
int main() | |
{ | |
int ch; | |
char pword[BUFSIZ]; | |
int i = 0; | |
puts ("Enter your password"); | |
fflush(stdout); | |
while ((ch = getch()) != EOF | |
&& ch != '\n' | |
&& ch != '\r' | |
&& i < sizeof(pword) - 1) | |
{ | |
if (ch == '\b' && i > 0) | |
{ | |
printf("\b \b"); | |
fflush(stdout); | |
i--; | |
pword[i] = '\0'; | |
} | |
else if (isalnum(ch)) | |
{ | |
putchar('*'); | |
pword[i++] = (char)ch; | |
} | |
} | |
pword[i] = '\0'; | |
printf ("\nYou entered >%s<", pword); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment