zhonghui1121
 1 #include<stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 typedef struct{
 5     char name[10];
 6     int  password;
 7 }guanli;
 8 
 9 int main(){
10     
12      guanli l;
13      
14     int pw;
15     int a;
16     char na[10];
17     strcpy(l.name , "zhonghui");
18     l.password= 123456;
19     printf("用户登录\n\n");
20     printf("请输入用户名:");
21     scanf("%s",na);
22     a=strcmp(l.name,na);
23     if(a==0)
24     {
25         printf("请输入密码:");
26         system("stty -echo");
27         scanf("%d",&pw);
28         system("stty -echo");
29         printf("\n");
30         if(pw == l.password)
31         {
32             printf("欢迎进入酒店管理系统\n");
33         }
34         else
35         {
36             printf("用户名错误\n\n");
37         }
38         return 0 ;
39     }
40 }

上面的代码其实也就两行有用,其他的代码只是为了实现它,就是上面我标红的地方,分别将两行代码加在你从键盘输入的上下行。

另外要加上#include<stdlib.h>的标准库文件。

1 system("stty -echo");
2 
3 
4 system("stty echo");

其中system(“stty -echo”)是设置命令不被显示

而  system("stty echo")是取消命令不被显示,两者要搭配使用不然你下面的输入都会无显示

分类:

技术点:

相关文章:

  • 2021-06-07
  • 2021-10-15
  • 2021-09-08
  • 2021-10-09
  • 2021-10-09
  • 2021-01-31
  • 2021-12-19
  • 2021-09-30
猜你喜欢
  • 2021-10-09
  • 2021-10-09
  • 2021-10-09
  • 2021-06-20
  • 2021-06-28
  • 2021-11-22
  • 2021-10-14
相关资源
相似解决方案