c语言 函数的使用
发布网友
发布时间:2022-04-23 05:49
我来回答
共1个回答
热心网友
时间:2023-10-17 09:12
搞个登录函数吧,成功返回0,否则返回-1
#include "stdio.h"
#include "conio.h"
#include "string.h"
int Login()
{ char a[40],b[40],d[40];
int c=0,rt=(-1);
while ( c<5 )
{
clrscr();
printf("Please input your QQ num: "); scanf("%s",a);
printf("Please input your password: "); scanf("%s",b);
clrscr();
printf("****************************************\n");
printf("This is your number and passwrod:\n");
printf("****************************************\n");
printf("* number: %s *\n",a);
printf("* password: %s *\n",b);
printf("****************************************\n");
printf("Please enter any key and press enter to determine.\n");
scanf("%s",d);
if ( strcmp(a,"1456680570")==0 )
{ if ( strcpm(b,"canfeng")==0 )
{
printf("Login success!\n"); rt=0; break;
} else printf("Password error!\n");
} else printf("Account error!\n");
c++;
}
}
void main()
{
if ( Login()==0 ) { .... }
}