Login verification

account number :admin

password :123456 
#include<stdio.h> #include<windows.h>//gotoxy #include<conio.h>//getch
#include<string.h>//strcmp #define ROW 14 #define COL 14 void gotoxy(int x,int
y)// Formal parameter { HANDLE hOut; COORD pos= {x,y}; // Starting position of cursor ( Section 1 column , Section 3 that 's ok ) 0 Yes, No 1 column 2 Yes, No 3 that 's ok hOut =
GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOut, pos);
//printf(" Positioning cursor position search (%d,%d)\n",pos.X,pos.Y); } void paintWindow() // User login window { int
startX=6; int startY=5; int width=20; int height=20; int i=0; // Print top // Cursor positioning Find rules
┗ ┛ ┏ ┓ ┃ ━ // Top y unchanged x Changing (x-x+w) gotoxy(startX,startY); printf("┏");
for(i=0;i<width-2;i++) // Number of control cycles width-2 second { printf("━ "); } printf("┓"); // left x unchanged
y Changing (y reach y+height) for(i=1;i<=height-2;i++) { gotoxy(startX,startY+i);
printf("┃"); } // right x unchanged =startx+width-1 y Changing y reach y+height
for(i=1;i<=height-2;i++) { gotoxy(startX+width*2-3,startY+i); printf("┃"); }
// bottom x in flux y unchanged (x reach x+width) ━ gotoxy(startX,startY+height-1); printf("┗");
for(i=0;i<width-2;i++) { printf("━ "); } printf("┛");
gotoxy(startX,startX+height); } void login() // User login interface { char ch=0; int i=0;
char name[9]={0};// Character array partial initialization char pwd[9]={0};// Character array partial initialization // Draw a window
paintWindow(); // Draw title label gotoxy(21,9); printf(" Login window "); gotoxy(6+5,12);
printf(" account number :"); gotoxy(6+5,16); printf(" password :"); gotoxy(18,12);// The cursor is positioned where the user name is entered
// Input of user name storage while(1) { ch=getch(); if(ch=='\r'&&i==0) // I didn't lose anything { continue; }
if(ch=='\r'&&i>0||i==8) // Length up to eight digits { break; } if(ch>='0'&&ch<='9' ||
ch>='a'&&ch<='z'|| ch>='A'&&ch<='Z') { putch(ch); name[i]=ch; ++i; } }
gotoxy(18,16); // The cursor is positioned at the position of password input i=0;// Use the same counter Reset required // Password input storage while(1) {
ch=getch(); if(ch=='\r'&&i==0) // I didn't lose anything { continue; } if(ch=='\r'&&i>0||i==8)
// Length up to eight digits { break; } if(ch>='0'&&ch<='9' || ch>='a'&&ch<='z'|| ch>='A'&&ch<='Z')
{ putch('*'); pwd[i]=ch; ++i; } } gotoxy(15,18); // Show login success Login failed
if(strcmp(name,"admin")==0&&strcmp(pwd,"123456")==0) { printf(" Login successful \n"); } else
{ printf(" Login failed \n"); } gotoxy(0,27); // validate logon admin 123456 } int main() { login();
return 0; }
result :

 

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq