是否可以用C语言实现我们在网页上看到的密码字段???
最佳答案
此代码可以达到以下目的:-
#include <stdio.h>
#include <conio.h>
#define MAX 25
#define passfield 1
void main()
{
char password[MAX], passchar;
int i=0;
clrscr();
printf("Enter password: ");
while(passfield)
{
passchar=getch();
if(passchar==13)
break; // 13 is the ASCII value of ENTER
if(passchar==8) // 8 is the ASCII value of BACKSPACE
{
putch('\b');
putch(NULL);
putch('\b');
--i;
continue;
}
password[i++]=passchar; //else store characters in password
passchar='*'; //mask password character
putch(passchar);
}
password[i]='\0'; //end of the char array
printf("\n%s",password);
getch();
}
关于c - 使用 C 实现密码字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8550447/