2个回答
展开全部
一个比较先进的,呵呵!还可以退格!
/*所谓的输入密码程序2*/
/*2005-10-23 梁见斌*/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define MAX 100
#define BACKSPACE 8
int main(void)
{
char passwords[MAX+1], ch;
int i=0;
puts("Input the passwords:");
while((ch = getch()) != '\r' && i < MAX)
{
if (ch == BACKSPACE)
{
if (i > 0)
{
passwords[--i] = NULL;
printf("\b ");
printf("%c%c%c", BACKSPACE, ' ', BACKSPACE);
}
else
putchar(7); //bell
}
else
{
passwords[i++] = ch;
printf("*");
}
}
passwords[i] = '\0';
printf("\nYour passwords is: ");
puts(passwords);
system("pause");
return 0;
}
/*所谓的输入密码程序2*/
/*2005-10-23 梁见斌*/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define MAX 100
#define BACKSPACE 8
int main(void)
{
char passwords[MAX+1], ch;
int i=0;
puts("Input the passwords:");
while((ch = getch()) != '\r' && i < MAX)
{
if (ch == BACKSPACE)
{
if (i > 0)
{
passwords[--i] = NULL;
printf("\b ");
printf("%c%c%c", BACKSPACE, ' ', BACKSPACE);
}
else
putchar(7); //bell
}
else
{
passwords[i++] = ch;
printf("*");
}
}
passwords[i] = '\0';
printf("\nYour passwords is: ");
puts(passwords);
system("pause");
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询