C Language: Analog implementation of a password to enter the automatic withdrawal program

Source: Internet
Author: User

Simulate a program to enter a password for automatic withdrawals

Program:

#include <stdio.h>

#include <windows.h>

#include <string.h>

int Main ()

{

Char *p = "123456" ;

Char passwd[10];

int i = 0;

for (i = 0; i < 3; i++)

{

printf ("Please enter password (up to 9 digits):");

scanf ("%s", passwd);

if (strcmp (p, passwd) = = 0) //Same as 0, password correct

{

Break ;

}

Else

{

printf ("Password input error!\n");

}

}

if (i = = 3)

{

printf ("three times password input error, shut down the system after 5 seconds \ n");

Sleep (5000);

}

Else if (i<3)

{

printf ("take money successfully \ \");

}

return 0;

}

Result 1:

Please enter your password (maximum 9 digits): 1237689

Password input Error!

Please enter your password (maximum 9 digits): 943209

Password input Error!

Please enter your password (maximum 9 digits): 123456

Take money to succeed

Please press any key to continue ...

Result 2:

Please enter your password (maximum 9 digits): 132147

Password input Error!

Please enter your password (maximum 9 digits): 98574

Password input Error!

Please enter your password (maximum 9 digits): 07534

Password input Error!

Three password input errors, shutting down the system after 5 seconds

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/1720166

C Language: Analog implementation of a password to enter the automatic withdrawal program

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.