当前位置:网站首页>About student management system (registration, login, student side)
About student management system (registration, login, student side)
2022-07-25 09:53:00 【Hills and valleys】
Tips : When the article is finished , Directories can be generated automatically , How to generate it, please refer to the help document on the right
List of articles
Preface
Here is the implementation of some small modules of the student management system :
Tips : The following is the main body of this article , The following cases can be used for reference
One 、 Registration module
How to write the registration module ?
1. First, you need to create a file to save the registered account and password , This eliminates the need to re register every time you log in , Just check whether this account exists in the file when logging in
2. Then we need to judge whether the account number entered each time is legal .( It refers to whether the entered student ID really exists ) At this time, we also need a file , To store all the student information that can be used to register .
So we need to judge whether the account number entered by the user corresponds Real students , And this account Not registered , You also need to check Save the account and password .
1. Registration module
void zhuce() {
// Here is the registration module
Sleep(1000);
system("cls");
// Registered account
printf(" Please enter your account number :");
char num[NUM_S];
scanf("%s", num);
Node* head = (Node*)malloc(sizeof(Node));
head = duqu_class1();// Here is to find out whether the account is legal
int k = -1;
while (head) {
if (strcmp(head->num, num) == 0) {
k = 0;
break;
} else {
k = 1;
head = head->next;
}
}
if (k == 1) {
printf(" I can't find your account , Please re-enter !\n");
zhuce();
}
struct count* count = (struct count*)malloc(sizeof(count));
count = duqu_count();// Judge whether the entered account has been registered
while (count) {
if (strcmp(count->num, num) == 0) {
printf(" This account has been registered , Please re-enter :\n");
zhuce();
break;
} else {
k = 2;
count = count->next;
}
}
char password1[PASS_S];// When the account is legal and not registered, you will come to this step
char password2[PASS_S];// We need to ask the user to enter the password twice , Achieve the purpose of determining the password
if (k == 2) {
printf(" Please input a password :");
scanf("%s", password1);
printf(" Please confirm the password :");
scanf("%s", password2);
if (strcmp(password1, password2) == 0) {
// There is no direct comparison here password1 and password2, Because they are all string types , The variable name should be a string address
printf(" Registered successfully !\n");
struct count* Head = (struct count*)malloc(sizeof(struct count));
struct count* p = Head;
strcpy(Head->num, num);
strcpy(Head->password, password1);
// It should be noted that you can't directly let Head->password=password
//password Is a string , You should use strcpy Function to copy it , The reason and the above strcmp The same function
save_count(Head);// For accounts that have been successfully registered , It should be saved in the account file
Head->next = NULL;
Head = Head->next;
}
} else {
// When the passwords entered twice are inconsistent , The user will be prompted that the passwords entered are inconsistent , Then return to the registration page
printf(" The two passwords are not the same ! Please re-enter :\n");
zhuce();
}
}
2. Judge whether the account exists
Read the information in the file ( There needs to be a named class1.txt The file of ), Read this file
Node* duqu_class1() {
// Read the information in the file into the linked list
Sleep(1000);
system("cls");
FILE* fp;
fp = fopen("class1.txt", "r");
Node* head, * p, * end;
head = p = (Node*)malloc(sizeof(Node));
while (!feof(fp)) {
end = (Node*)malloc(sizeof(Node));
fscanf(fp, "%s %s %s %d %d %d\n", end->name, end->num, end->class, &end->score1, &end->score2, &end->score3);
p->next = end;
p = end;
}
fclose(fp);
head = head->next;
p->next = NULL;
return head;
}
3. Judge whether the account is not registered
Here is the function to judge whether the read account has been registered , Note the return type of the function here (count.txt) It is a file used to store all registered accounts and passwords
struct count* duqu_count() {
Sleep(1000);
system("cls");
FILE* fp = fopen("count.txt", "r");
if (fp == NULL) {
perror(fopen);
return;
}
struct count* Head, * p, * end;
Head = p = (struct count*)malloc(sizeof(struct count));
while (!feof(fp)) {
end = (struct count*)malloc(sizeof(struct count));
fscanf(fp, "%s %s\n", end->num, end->password);
p->next = end;
p = end;
}
fclose(fp);
Head = Head->next;
p->next = NULL;
return Head;
}
4. Save the successfully registered account
Here is the function to save the successfully registered account and password , We still save the successfully registered account and password to count.txt In file
void save_count(struct count* head) {
// Save the registered account
Sleep(1000);
system("cls");
struct count* con = (struct count*)malloc(sizeof(struct count));
FILE* fp;
fp = fopen("count.txt", "a");
if (fp == NULL) {
perror(fopen);
} else {
con = head;
struct count* Headcount = con;
fprintf(fp, "%s %s\n", con->num, con->password);
con = con->next;
printf(" The account and password have been saved successfully !\n");
fclose(fp);
}
}
Two 、 Login module
1. Sign in
When the user enters , We only need Read the previous file storing the account and password , Just check whether the account number and password entered by the user are correct .
void denglu_stu() {
// Log in to the student account
Sleep(1000);
system("cls");
char num[NUM_S];
printf(" Please enter your account number :");
scanf("%s", num);
char password[PASS_S];
printf(" Please input a password :");
scanf("%s", password);
int i = 0;
struct count* Head = duqu_count();
// This function has been previously declared , Don't explain too much
while (Head) {
if (strcmp(Head->num, num) == 0 && strcmp(Head->password, password) == 0) {
printf(" Login successful !\n");
menu_stu();
i = 1;
break;
} else {
Head = Head->next;
}
}
if (i != 1) {
printf(" The student number or password entered is incorrect , Or this student ID has not been registered !\n");
}
}
3、 ... and . Students check their scores
struct student* Head=NULL;
Head = duqu_class1();
// It is still the previous function of reading student information
char num[NUM_S];
printf(" Please enter your student number :\n");
scanf("%s", num);
int i = 0;
while (Head) {
if (strcmp(Head->num, num) == 0) {
printf("%d %d %d", Head->score1, Head->score2, Head->score3);
i = 1;
break;
} else {
Head = Head->next;
}
}
if (i != 1) {
printf(" The student number entered is incorrect , Please re-enter !\n");
chaxun(k);
}
Four . Students check their grades
struct student* Head=NULL;
Head = duqu_class1();
while (Head) {
printf("%5s %5s %5s %5d %5d %5d\n", Head->name, Head->num, Head->class, Head->score1, Head->score2, Head->score3);
Head = Head->next;
}
summary
Register in the student management system , Login and other modules , Note that we need to operate the file . Be sure to pay attention to the way the file is opened , Otherwise, you may find that you have got another empty file after the operation .
边栏推荐
- A number converted from a decimal integer to another base
- Some usages of Matlab's find() function (quickly find qualified values)
- 单目深度估计自监督模型Featdepth解读(上)——论文理解和核心源码分析
- CDA Level1多选题精选
- Expect+sh realize automatic interaction
- 初识Opencv4.X----图像直方图均衡
- Introducing MLOps 解读(一)
- matlab如何导入大量数据
- CDA LEVELⅠ2021新版模拟题二(附答案)
- 无向连通图邻接表的创建输出广度深度遍历
猜你喜欢

@1-1 CCF 2021-04-1 gray histogram

Hyperautomation for the enhancement of automation in industries 论文翻译

【深度学习】卷积神经网络

深度估计自监督模型monodepth2论文总结和源码分析【理论部分】

CUDA 解释 - 深度学习为何使用 GPU

初识Opencv4.X----在图像上绘制形状

数据分析业务核心

Server CUDA toolkit multi version switching

Preliminary understanding and implementation of wechat applet bottom navigation bar

初识Opencv4.X----图像直方图绘制
随机推荐
卷积神经网络发展历程(部分)
Binary Cross Entropy真的适合多标签分类吗?
基于PackNet的演进——丰田研究院(TRI)深度估计文章盘点(上)
Chmod and chown invalidate the files of the mounted partition
MLX90640 红外热成像仪测温模块开发笔记(五)
Flutter rive multi state example
How to import a large amount of data in MATLAB
matlab如何导入大量数据
pytorch使用tensorboard实现可视化总结
ARM GIC简介
Gartner 2022年顶尖科技趋势之超级自动化
CDA Level1知识点总结之多维数据透视分析
缺陷检测网络--混合监督(kolektor缺陷数据集复现)
How to install pytorch—— A most simple and effective method!
Expect+sh realize automatic interaction
Create personal extreme writing process - reprint
深度学习 段错误(Segment Core/ Exit code 139)情况记录
【降维打击】希尔伯特曲线
@3-2 optimal threshold of CCF 2020-12-2 final forecast
MinkowskiEngine 安装