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