⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regist.c

📁 此版本是在网上广为流传的 二级文件系统 基础上制作的.重新编写了块操作等模块,修正了N多BUG. 实现的命令有 ls-列目录 md-创建目录 cd-进入子目录 mf-创建文件 cat-显示文件内
💻 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 + -