<>C/C++ Language implementation landing interface

<> Introduction to overall functions

/***********************************************************
Implementation of a landing interface
1 Output a login interface
2 User name can realize mailbox verification ,regex library , The password is not visible
3 Simulation of progress bar
4 Music playing
***************************************************************/

<> Step by step

<>1. Output a login interface

First of all, the function used in this function is briefly introduced .

<>(1).system();

int system(const char *command) hold command
The specified command name or program name is passed to the host environment to be executed by the command processor , And returns when the command is complete . You need to include a header file to use this function :#include <stdlib.h>

*<1> Adjustment window

* system function +dos instructions
* title :title Title name
* colour :color f0
* size :mode con cols = 40 lins =8;// You can define it yourself here cols and lins size
* for example :
* system("calc"); Open calculator “” Inside are the computer commands .
* system("pause");// Flash proof screen
realization
void setWindosStyle(void) { system("title Email verification "); system("color f0"); system(
"mode con cols=40 lines=8"); }
<>2. User and password

The password is invisible here , Therefore, it can be used _getch() function , You can choose Baidu by yourself .
void setUserNamPass(uin8_t* username, uin8_t* userpassword) { cout << "\t user name :";
cin>> username; cout << "\t dense code :"; //cin >> userpassword; // Password not visible : Strings are treated as characters //
Output one at a time * It's No.1 , Then save all the keys to the password inside char key; uin32_t i = 0; while ((key = _getch
()) != '\r') { if (i < 6) { userpassword[i++] = key; putchar('*'); } else { cout
<< " The password is too long " << endl; system("pause"); return; } } // String end tag :\0; userpassword[i] =
'\0'; }
<>3. Email verification

This function is used to determine whether the input needs to construct a regular expression object , Then call regex_match() Function to determine whether the input string meets the requirements ; Use to C++ Header file #include .
bool checkEmail(uin8_t* username) { bool result = false; //ctb @163 .com.cn
regexobject("(\\w+)@(\\w+)(\\.(\\w+))+"); /*1. letter a-z A-Z Or underline or 0-9, regular expression */ //+
Multiple result = regex_match(username, object); return result; }
<>4. Simulation of progress bar

This function uses the #include <Windows.h> Header file Sleep() function .
void proc(void) { string str("-"); for (uin32_t i = 0; i <= 20; i++) { system(
"cls"); cout << str << endl; cout << i * 5 << "%" << endl; str += "-"; Sleep(500
); } printf("sucess....!\n"); }
<>5 . Play music

This function is used to #include(mmsystem.h) In the header file mciSendString() function , Baidu can understand the function .
First download a piece of music MPS file , Then copy it to this process project directory . be careful : To realize this function, static package should be loaded ,

* #pragma comment(lib,“winmm.lib”)// Loading static package void palyMusic(void) { mciSendString
("open 1.mp3 alias music", 0, 0, 0); mciSendString("play music repeat", 0, 0, 0)
; }
<>6. test

<><1>. Header file
//#pragma once #ifndef _TEST_H_ #define _TEST_H_ typedef int uin32_t; typedef
char uin8_t; #include<iostream> #include <cstdio>//c++ Reference standards , Generally c+ Original file name #
include <conio.h>//_getch() #include <regex>// regular expression #include <string> #include
<Windows.h> #include <mmsystem.h> using namespace std; void setWindosStyle();
void setUserNamPass(uin8_t* username, uin8_t*userpassword); bool checkEmail(
uin8_t* username); void proc(void); void palyMusic(void); #endif // !_TEST_H_
<><2>.main function
#include "test.h" uin32_t main(void) { // user name + password uin8_t username[20] = "";
uin8_t userpassword[7] = ""; setWindosStyle(); setUserNamPass(username,
userpassword); if ((checkEmail(username)) == true) { if (!(strcmp(username,
"ctb@163.com.cn")&&strcmp(userpassword,"12345"))) { // Pop up progress bar proc(); cout <<
"music begin!!!" << endl; // It's playing music palyMusic(); } else { cout << " Wrong user name or password " <<
endl; } } else { printf("inpute email name no standard\n"); } system("pause");
return 0; }

Technology
©2019-2020 Toolsou All rights reserved,
Huawei 2021 session Hardware Engineer Logical post (FPGA) Super detailed surface !!!Vue-element-admin upgrade ui edition virtual machine VMware Download and install the most detailed tutorial !C++ Move constructor and copy constructor sound of dripping water java Backstage interview pygame Realize full screen mode and adjustable window size mysql Database setting character set configuration modification my.ini file (windows)30 What's the experience of being a junior programmer at the age of 20 C++ Multithreading programming ( Summary of common functions and parameters )python_ cherry tree