KimYDae 2022-06-04 23:11 采纳率: 83.5%
浏览 743
已结题

比较用户键盘输入的口令userInput与内设的口令password是否相同

比较用户键盘输入的口令userInput与内设的口令password是否相同


#include <stdio.h>
#include <string.h>
int main()
{
    char password[7] = "secret";    
    char userInput[81] ;
    printf("Input Password:");
    scanf(_____________);//第8行
    if ( ______________ )//第9行
        printf("Correct password! Welcome to the system...\n");
    else if ( ___________________) //第11行
   
        printf("Invalid password!user input<password\n");
    else
        printf("Invalid password!user input>password\n");   
    return 0;
}

能给个大致思路吗?谢谢!

  • 写回答

1条回答 默认 最新

  • Hann Yang 全栈领域优质创作者 2022-06-05 00:48
    关注
    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
        char password[7] = "secret";    
        char userInput[81] ;
        printf("Input Password:");
        scanf("%s", userInput);//第8行
        if ( strcmp(userInput,password)==0 )//第9行
            printf("Correct password! Welcome to the system...\n");
        else if ( strcmp(userInput,password)<0 ) //第11行
            printf("Invalid password!user input<password\n");
        else
            printf("Invalid password!user input>password\n");   
        return 0;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 6月13日
  • 已采纳回答 6月5日
  • 创建了问题 6月4日

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器