gpt4 book ai didi

c - 使用 C 实现密码字段

转载 作者:行者123 更新时间:2023-11-30 19:50:05 25 4
gpt4 key购买 nike

是否可以用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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com