如何在系统turbo C中创建日志 [英] How do I create a log in system turbo C
本文介绍了如何在系统turbo C中创建日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要登录系统,尝试登录3次,密码应为*
请帮我。我在这里有一个代码,但我不知道如何输入密码*请帮助。
我尝试过: < br $>
I need a log in system that has a 3 attempts log in, and the password should be "*"
Please help me. I have a code here but i dont know how to input a password to "*" Please help.
What I have tried:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char u[10],p[10],user[]="lokesh",pas[]="spiderman";
int n=0;
clrscr();
printf("\n press enter and enter username and password(only
3 attempts)");
while(n<=2)
{
printf("\n Username: ");
scanf("%s",&u);
printf("\n Password: ");
scanf("%s",&p);
if(strcmp(user,u)==0 && strcmp(pas,p)==0)
{
printf("\n Congratulations!");
break;
}
else
{
n++;
printf("\n the username or password is incorrect. only %d
trials left. press enter", 3-n);
}
}
if(n==3)
{
printf("\n you have used maximum attempts(3). please try
later.");
}
getch();
}
推荐答案
一个不错的密码实施,与Jochen提出的一样,但具有其他功能。 (关闭Q& A)
A nice pasword implementation which works as Jochen proposed, but with other function. (to close the Q&A)
这篇关于如何在系统turbo C中创建日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文