客户端的登录注册

来源:互联网 发布:amazon listing 优化 编辑:程序博客网 时间:2024/05/29 11:11
void reg(int sockfd){LOGIN *login = (LOGIN *)malloc(sizeof(LOGIN));printf("\t\tPlease input name:    ");scanf("%s",login -> name);printf("\t\tPlease input password: ");scanf("%s",login -> password);login -> action = REG;write(sockfd,login,sizeof(LOGIN));read(sockfd,login,sizeof(LOGIN));if(login -> action == 1){printf("\t\treg success!\n");}else if(login -> action == 5);{printf("\t\tThe User is already existed!");getchar();        getchar();}    return 0;}

int login(int sockfd){LOGIN *login = (LOGIN *)malloc(sizeof(LOGIN));int i;printf("\t\tPlease input usr name: ");scanf("%s",login -> name);printf("\t\tPlease input password: ");scanf("%s",login -> password);login -> action = LOG;write(sockfd,login,sizeof(LOGIN));read(sockfd,login,sizeof(LOGIN));switch(login -> action){case 1:{return 1;}case -2:{printf("\t\tNo this User,Please reg!\n");getchar();getchar();return -1;}case -1:{printf("\t\tThe password is wrong!\n");getchar();getchar();return -2;}default :{return 0;}}

0 0