c語言編程登陸密碼問題
阿新 • • 發佈:2019-03-25
輸入密碼 else printf 輸入 問題 stdlib.h code turn 錯誤 密碼123456可以修改;
登陸三次退出程序
登陸三次退出程序
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i = 0; char password[20] = { 0 }; for (i = 0; i < 3; i++) { printf("請輸入密碼:>"); scanf("%s", password);//"123456" if (strcmp(password, "123456") == 0)//string compare { printf("登錄成功\n"); break; } else { printf("密碼輸入錯誤,請重新輸入!\n"); } } if (i == 3) { printf("\n\n三次密碼均輸入錯誤,退出程序\n"); } return 0; }
c語言編程登陸密碼問題