regist.c
来自「此版本是在网上广为流传的 二级文件系统 基础上制作的.重新编写了块操作等模块,修」· C语言 代码 · 共 49 行
C
49 行
#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 + =
减小字号Ctrl + -
显示快捷键?