C: Analog Three-time password input.

Source: Internet
Author: User

Simulates three password entries.

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 ("Please enter password:");

scanf ("%s", arr);

if (strcmp (P,arr) ==0)

{

Break ;

}

Else  

{

printf ("Password error!\n");

}

}

if (i==3)

{

printf ("three times password input error, the system will automatically shut down after 3 seconds!") \ n ");

Sleep (3000);

}

Else if(i<3)

{

printf ("Congratulations on your successful login!") \ n ");

}

return 0;

}

Result 1:

Please enter the password : 123567

Wrong password !

Please enter the password : 65848

Wrong password !

Please enter the password : 135268

Wrong password !

Three times the password input error, the system will automatically shut down after 3 seconds!

Please press any key to continue ...

Result 2:

Please enter the password : 123456

Congratulations on your successful login!

Please press any key to continue ...


This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1720171

C: Analog Three-time password input.

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.