#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include<conio.h>
int main(){
char Password[100],str[100]="admin";
strcpy(Password,str);
printf("%s\n",Password);
char str43[100];
int CSS=0;
while(str43[CSS]=getch())
{
if(str43[CSS]==13){
break;
}
if(str43[CSS]!='\b'){
printf("*");
CSS++;
}
else{
printf("\b \b");
CSS--;
}
}
str43[CSS]='\0';
printf("\n");
printf("%s\n",str43);
GATE:
if(strcmp(str43,Password)==0)
{
printf("Yes\n");
}
else
{
printf("Invalid password.\n");
printf("Enter the password:");
while(str43[CSS]=getch())
{
if(str43[CSS]==13){
break;
}
if(str43[CSS]!='\b'){
printf("*");
CSS++;
}
else{
printf("\b \b");
CSS--;
}
}
str43[CSS]='\0';
printf("\n");
goto GATE;
}
return 0;
}
C语言 判断密码是否正确并返回 可以判断是否正确,但是密码错误后就没办法判断
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 书山客 2021-12-17 09:49关注
#include <stdio.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include<conio.h> int main() { char Password[100] = {0}, str[100] = "admin"; strcpy(Password, str); printf("%s\n", Password); char str43[100]; int CSS = 0; while (str43[CSS] = getch()) { if (str43[CSS] == 13) { break; } if (str43[CSS] != '\b') { printf("*"); CSS++; } else { printf("\b \b"); CSS--; } } str43[CSS] = '\0'; printf("\n"); printf("%s\n", str43); GATE: if (strcmp(str43, Password) == 0) { printf("Yes\n"); } else { CSS = 0; str43[0]='\0'; printf("Invalid password.\n"); printf("Enter the password:"); while (str43[CSS] = getch()) { if (str43[CSS] == 13) { break; } if (str43[CSS] != '\b') { printf("*"); CSS++; } else { printf("\b \b"); CSS--; } } str43[CSS] = '\0'; printf("\n"); goto GATE; } return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 2024-五一综合模拟赛
- ¥15 下图接收小电路,谁知道原理
- ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
- ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
- ¥15 手机接入宽带网线,如何释放宽带全部速度
- ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
- ¥15 ETLCloud 处理json多层级问题
- ¥15 matlab中使用gurobi时报错
- ¥15 这个主板怎么能扩出一两个sata口
- ¥15 不是,这到底错哪儿了😭