首先主要用到的头文件是:#include<conio.h>;
使用的函数是:int getch();
代码如下:
#include<stdio.h>
#include<conio.h>
#define MAX_SIZE 100
int main(void)
{
char pass[MAX_SIZE]="";//声明并开辟空间,注意如果不初始化会出现乱码
int asc=0,num=0;
printf("insert your password\n");
while(1)
{
asc=getch();
if(asc!=13)//数字'13'是回车键的ASCII代码值
{
pass[num]+=(char)asc;
num++;
printf("*");//密码掩盖
}
else
{
break;
}
}
printf("\n");
printf("%s\n",pass);
return 0;
}
C语言中如何做到密码掩盖
最新推荐文章于 2021-12-28 15:39:59 发布