1.C语言中如何能把用户输入的密码变成星号代替
我这个程序是控制台程序 不知道你问的是不是这个意思啊 你建个控制台程序运行一个看看吧! 如果有回答的不是你想问的,或者有什么问题 请追问! 程序代码如下: #include#includevoid main() { char a=0; while((a = getch()) != 0x0d) { printf("*"); } } 还有一个稍微复杂一些的: #include#include#define MAX 6 void main() { char array[MAX]={0}; int i=0; printf("please enter the password:"); for(i=0; i
2.C语言怎样加密码变成星号
#include
#include
#include
#include
int chcode() {
char pw[50],ch;
char *syspw = "abc"; // 原始密码
int i,m = 0;
printf("请输入密码:");
while(m < 3) {
i = 0;
while((ch = _getch()) != '\r') {
if(ch == '\b' && i > 0) {
printf("\b \b");
--i;
}
else if(ch != '\b') {
pw[i++] = ch;
printf("*");
}
}
pw[i] = '\0';
printf("\n");
if(strcmp(pw,syspw) != 0) {
printf("密码错误,请重新输入!\n");
m++;
}
else {
printf("密码正确!\n");
system("pause");
return 1;
}
}
printf("连续3次输入错误,退出!\n");
system("pause");
r