具有密碼輸入隱藏功能(c語言編)

/*這個例子很簡單的就把密碼輸入隱藏功能呈現出來,關鍵的一點就是system(“cls”),與大家分享*/

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
 
int ch,i; 
int count=0; 
char passwd[128]; 
while((ch=getch())!=13)
{
if(ch==8)
{
 
  system("cls");
  for(i=(--count);i>0;i--)
  printf("*");
  passwd[count]=' ';
}
 
else
{
printf("*");
passwd[count++]=ch;
 
}
}
 
passwd[count]='\0' ;
printf("\nThe password you have inputed is : %s\n",passwd);
getch();
}
 
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章