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.