代码:
#include <stdio.h>#include <string.h>int main() { char username[20]; char password[20]; int login_attempts = 0; printf("Welcome to the login page!\n"); while (login_attempts < 3) { printf("Please enter your username: "); scanf("%s", username); printf("Please enter your password: "); scanf("%s", password); if (strcmp(username, "admin") == 0 && strcmp(password, "password") == 0) { printf("Login successful!\n"); break; } else { printf("Incorrect username or password. Please try again.\n"); login_attempts++; } } if (login_attempts == 3) { printf("Too many login attempts. Please try again later.\n"); } return 0;}
如果觉得《C语言写登录界面实现》对你有帮助,请点赞、收藏,并留下你的观点哦!