C language: Simulate Password Input three times.

Source: Internet
Author: User

C language: Simulate Password Input three times.
Simulate Password Input three times. Solution: Program:

# Include <stdio. h> # include <windows. h> # include <string. h> int main () {int I; char * p = "123456"; char arr [10]; for (I = 0; I <3; I ++) {printf ("Enter Password:"); scanf ("% s", arr); if (strcmp (p, arr) = 0) {break ;} else {printf ("Incorrect password! \ N ") ;}}if (I = 3) {printf (" three times wrong password input, the system will automatically close in 3 seconds! \ N "); Sleep (3000);} else if (I <3) {printf (" Congratulations! \ N ") ;}return 0 ;}

 

Result 1: The password 123567 is incorrect! Enter Password: 65848 incorrect password! Enter Password: 135268 incorrect password! The password entered three times is incorrect. The system will automatically shut down 3 seconds later! Press any key to continue... result 2: Enter Password: 123456. Congratulations, your logon is successful! Press any key to continue...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.