?? regist.c
字號:
#include <stdio.h>
#include "filesys.h"
void regist(int id)
{
char tempname[FILENAMELEN];
char temp[FILENAMELEN];
char temppassword[FILENAMELEN];
int i;
printf("---------regist---------\n");
if ( strcmp(user[id].u_name, "root") ) {
printf("You can't regist a new user!\n");
return;
}
for (i = 0; i < USERNUM; ++i) {
if ( !strcmp(user[i].u_name, "") && !user[i].u_gid && !user[i].u_gid ){
printf("Please input your user name(Max 11 characters):");
scanf("%s",tempname);
printf("Please input your password(Max ll characters):");
scanf("%s",temp);
printf("'Please input your password again:");
scanf("%s",temppassword);
if(strcmp(temppassword,temp)==0)
{
printf("OK!You have register !You can login your accounts./n");
strcpy(user[i].u_name,tempname);
strcpy(user[i].password,temppassword);
user[i].u_uid = ( temppassword[0]*34 + tempname[0]*12 ) % 2000;
user[i].u_gid = 0;
fseek(fd,DATASTART+2*BLOCKSIZ,SEEK_SET);
fwrite(user,1,BLOCKSIZ,fd);
break;
}
else
{
printf("Sorry!Password incorrect-You can’t login/n");
}
}
}
if (i>=8)
{
printf("Registered user has already fulld./n");
}
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -