📄 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 + -