16,471
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#define max 1024
struct record
{
char name[max];
char number[max];
char pwd[max];
}rec[4];
struct entry
{
char name[max];
char pwd[max];
}log;
char system(int j);
int main(void)
{
scanf("%s",rec[0].name);
scanf("%s",rec[0].pwd);
int i;
puts("What do u want to do(Input the number)?\n 1. Login 2.Registe 3.Exit");
for(i=0;i!=1 || i!=2 || i!=3;)
{
scanf("%d",&i);
if(i==1)
break;
else
{
scanf("%d",&i);
printf("Please input the right number:");
}
}
switch(i)
{
case 1 :
{
system(i);
break;
}
case 2 :
{
system(i);
break;
}
case 3 :
{
system(i);
break;
}
}
system("pause");
return 0;
}
char system(int j)
{
if(j==1)
{
puts("Enter you name:");
scanf("%s",log.name);
puts("Enter your password:");
scanf("%s",log.pwd);
/* Check the name and password 出问题代码 if((rec[m].name)==log.name) 和 if(rec[m].pwd==log.pwd) 还有 if((rec[m].name== log.name )&&(rec[m].pwd==log.pwd))
*/
int m,n;
for(m=0;m<4;m++)
{
printf("%s\n",rec[m].name);
if((rec[m].name)==log.name)
{
printf("the rec name is %s",rec[m].name,log.name);
for(n=0;n<4;n++)
{
if(rec[m].pwd==log.pwd)
{
printf("Welcome back,%s",log.name);
break;
}
}
break;
}
else
continue;
}
if((rec[m].name== log.name )&&(rec[m].pwd==log.pwd))
printf("Welcome back %s",log.name);
else
printf("Sorry,please recheck your name or password");
}
else if(j==2)
{
int i;
for(i=1;i<=4;i++)
{
if(rec[i].name==NULL)
break;
}
puts("Please input the information\n 1. Name:");
scanf("%s",rec[i].name);
puts("Please input the information\n 2.number:");
scanf("%s",rec[i].number);
puts("Please input the information\n 3. password:");
scanf("%s",rec[i].pwd);
printf("Your name is %s, your number is %s, your pwd is %s",rec[i].name,rec[i].number,rec[i].pwd);
}
else if(j==3)
{
exit(1);
system("pause");
}
else
return 0;
}