?? login.c
字號:
#include "main.h"#define L_MAX 1024int login(char *name,char *passwd){ FILE *fp; char *p,*q,*r; char buff[L_MAX]; if((p=strchr(name,'\n'))!=NULL) *p='\0'; if((p=strchr(passwd,'\n'))!=NULL) *p='\0'; if((fp=fopen("passwd","r"))==NULL) { printf("open passwd error!\n"); exit(1); } while((r=fgets(buff,sizeof(buff),fp))!=NULL) { p=strchr(buff,':'); q=p+1; *p='\0'; if(strcmp(name,buff)==0) { p=strchr(q,'\n'); *p='\0'; if(strcmp(passwd,q)!=0) { return (-1); } else { return 0; } } } if(r==NULL) { printf("username not existed !\nplease regist first !\n"); return (-1); } fclose(fp);}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -