当前位置:网站首页>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 .
边栏推荐
- Some usages of Matlab's find() function (quickly find qualified values)
- Evolution based on packnet -- review of depth estimation articles of Toyota Research Institute (TRI) (Part 1)
- 初识Opencv4.X----在图像上绘制形状
- UI prototype resources
- 初识Opencv4.X----图像直方图均衡
- CCF 201509-2 日期计算
- Gartner 2022年顶尖科技趋势之超级自动化
- T5论文总结
- Verdi 基础介绍
- 基于PackNet的演进——丰田研究院(TRI)深度估计文章盘点(下)
猜你喜欢

MLX90640 红外热成像仪测温模块开发笔记(四)

【降维打击】希尔伯特曲线

CCF 201509-4 高速公路

缺陷检测网络--混合监督(kolektor缺陷数据集复现)

如何安装pytorch?—— 一种最简单有效的方法!

¥ 1-3 SWUST OJ 942: reverse sequence table

Principle analysis of self supervised depth estimation of fish eye image and interpretation of omnidet core code

First knowledge of opencv4.x --- image convolution

How to add other PHP versions to MAMP

从鱼眼到环视到多任务王炸——盘点Valeo视觉深度估计经典文章(从FisheyeDistanceNet到OmniDet)(下)
随机推荐
Raspberry sect door ban system based on face recognition
AI模型风险评估 第1部分:动机
无向连通图邻接表的创建输出广度深度遍历
First knowledge of opencv4.x ---- mean filtering
【数据挖掘】第二章 认识数据
单目深度估计自监督模型Featdepth解读(上)——论文理解和核心源码分析
matlab绘图|坐标轴axis的一些常用设置
Mixed supervision for surface-defect detection: from weakly to fully supervised learning:表面缺陷检测的混合监督
【RNN】剖析RNN 之 从RNN-(Simple|LSTM) 到 序列生成 再到 seq2seq框架(encoder-decoder,或称为seq2seq)
Chmod and chown invalidate the files of the mounted partition
Evolution based on packnet -- review of depth estimation articles of Toyota Research Institute (TRI) (Part 2)
How to import a large amount of data in MATLAB
关于MLOps中的数据工程,你一定要知道的.......
ARMv8通用定时器简介
CCF 201512-4 送货
First knowledge of opencv4.x --- image template matching
CCF 201509-4 高速公路
低功耗和UPF介绍
Server CUDA toolkit multi version switching
[dimension reduction strike] Hilbert curve