1. 程式人生 > >C語言強化——學生管理系統

C語言強化——學生管理系統

next conf std info 管理系統 lis float 分享 char*

  • 系統模塊設計
    a.預處理模塊
    系統在啟動時會根據配置文件裏的內容去相應文件裏去加載賬戶信息和學生信息。
    b.登陸模塊

技術分享圖片

輸入用戶名和密碼,輸密碼的時候用“*” 代表用戶當前輸入的內容。Shift + “#” 代表輸入結束。

當用戶輸入完用戶名和密碼後,系統會拿它去跟內存中的用戶名和密碼匹配。如果匹配成功則進入系統菜單界面。如果匹配不成功則會直接退出程序。

c.系統功能菜單顯示
根據用戶名的權限不同顯示不同的功能,普通用戶只具有查詢學生信息的功能。
當用戶選擇查詢學生信息功能時會根據用戶權限的不同顯示不同功能的查詢功能。當前用戶為普通用戶時,

技術分享圖片

分為按姓名查詢和按學號查詢。3菜單返回上一層。

當前用戶為管理員用戶時,顯示為

技術分享圖片

多了一個功能。
系統提供的其他功能只有在管理員權限下才能使用。
技術分享圖片

菜單2 為添加學生信息,管理員從標準輸入輸入學生的詳細信息,系統會把學生信息按照學號的大小插入到內存的鏈表中,並同時把鏈表保存到相應文件中去。(註意:學生的學號是唯一的,如果兩學生的學號相同會插入失敗)

菜單3為修改學生的信息。管理員可以根據學號修改學生的其他信息(學號不能修改)。並同時將修改完的信息保存到到文件。

菜單4 為刪除學生的信息,管理員可以根據學生的學號刪除相應學生的信息。並同時把刪除後的學生信息保存到文件中去。

菜單5是增加賬號。所增加的賬號名不能與已存在的沖突。增加賬號完畢後同時把增加後的信息保存到相應的文件中去。

菜單 6 更新賬號信息。同時把信息保存到相應文件中去。
菜單7 刪除用戶賬戶。管理員根據輸入的賬戶名刪除相對應的賬戶。並把刪除後的信息保存到相應的文件中去。
菜單8 查詢用戶賬號信息。
菜單9 退出系統。並同時把信息保存到文件中去。

學生管理系統

SIMS.h

#pragma once
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>

#define FILE_NAME_LEN 300
#define USR_NAME_LEN 20
#define USR_PWD_LEN 10
#define USR_ROLE int 
#define SEARCH_ID int
#define USR_ACCOUNT_NUM int 
#define SYSTEM_MENU_TYPE int
#define USR_INFOR_NUM int

typedef struct usr_account_tag
{
    char usr_name[USR_NAME_LEN];     
    char usr_pwd[USR_PWD_LEN];
    USR_ROLE  usr_role;
    struct usr_account_tag *pNext_Usr_Account;
}USR_ACCOUNT, *pUSR_ACCOUNT;

typedef struct usr_infor_tag
{
    int usr_id;
    char usr_name[USR_NAME_LEN];
    int usr_course_id;
    float usr_course_score;
    struct usr_infor_tag *pNext_Usr_Infor;
}USR_INFOR, *pUSR_INFOR;



void printlist1(pUSR_ACCOUNT pUsr_Acount);
void printlist2(pUSR_INFOR pUsr_Infor);

void system_init(const char* config_file_name, pUSR_ACCOUNT  *pUsr_Acount, pUSR_INFOR *pUsr_Infor);
//系統初始化函數。初始化內存中的學生信息鏈表和賬號列表。

USR_ROLE role_confirm(pUSR_ACCOUNT pUsr_Account);
//根據輸入的用戶名和密碼檢查是否合法並確認當前賬號的權限(管理員或普通用戶)

SYSTEM_MENU_TYPE show_system_menu(USR_ROLE role);
//顯示系統菜單,返回當前用戶所選擇的菜單

SYSTEM_MENU_TYPE show_search_menu(USR_ROLE role);
//當前用戶選擇查詢功能時根據權限顯示具有不同功能的查詢功能的菜單

void search_usr_infor_all(pUSR_INFOR pUsr_Infor_List);
//顯示所有學生信息

void search_usr_infor_by_id(pUSR_INFOR pUsr_Infor_List, SEARCH_ID search_id);
//根據當前用戶所輸的學號查詢相應的學生信息。

void search_usr_infor_by_name(pUSR_INFOR pUsr_Infor_List, char* search_name);
//根據當前用戶所輸的姓名查詢相應的學生信息。

pUSR_INFOR add_usr_infor(pUSR_INFOR *ppUsr_Infor_List);
//添加學生信息,返回指向插入的學生的指針

pUSR_INFOR update_usr_infor(pUSR_INFOR * pUsr_Infor_List, SEARCH_ID search_id);
//修改學生的信息,返回指向修改後的學生的信息的指針

pUSR_INFOR delete_usr_infor(pUSR_INFOR *ppUsr_Infor_List, SEARCH_ID search_id);
//刪除學生的信息, 是返回所刪除的學生的下一個學生的指針

void search_usr_account(pUSR_ACCOUNT pUsr_Account_List, char* search_name);
//根據當前賬號輸入的賬號名查詢相應的賬號信息。

pUSR_ACCOUNT add_usr_account(pUSR_ACCOUNT* ppUsr_Account_List);
//增加賬號信息,返回指向當前賬號的指針

pUSR_ACCOUNT update_usr_account(pUSR_ACCOUNT * pUsr_Account_List, char* search_name);
//修改賬號信息返回指向當前修改賬號的信息

pUSR_ACCOUNT delete_usr_account(pUSR_ACCOUNT *ppUsr_Account_List, char* search_name);
//刪除賬號信息,返回指向下一個賬號的指針

void save_data_to_file(char * config_file_name, pUSR_ACCOUNT pUsr_Account_List, pUSR_INFOR pUsr_Infor_List);
//將學生信息和賬號信息保存到文件裏去。

SIMS.c

#include "SIMS.h"

void system_init(const char * config_file_name, pUSR_ACCOUNT * pUsr_Acount, pUSR_INFOR * pUsr_Infor)
{
    FILE *fp;
    fp = fopen("configure.txt", "r");
    if (NULL == fp) {
        perror("fopen");
        return;
    }
    char buf[FILENAME_MAX];
    memset(buf, 0, sizeof(buf));
    char c;
    int num = 0;
    while ((c = fgetc(fp))!=EOF) {
        if (c == '\n') break;
        buf[num++] = c;
    }
    char * usr_account_file_loc = (char*)calloc(FILENAME_MAX,sizeof(char));
    strcpy(usr_account_file_loc, buf);

    memset(buf, 0, sizeof(buf));
    num = 0;
    while ((c = fgetc(fp)) != EOF) {
        buf[num++] = c;
    }
    char * usr_infor_file_loc = (char*)calloc(FILENAME_MAX, sizeof(char));
    strcpy(usr_infor_file_loc, buf);

    fclose(fp);

    FILE *fp2;
    
    fp2 = fopen(usr_account_file_loc, "r");
    if (NULL == fp2) {
        perror("fopen");
        return;
    }
    pUSR_ACCOUNT temp = (pUSR_ACCOUNT)calloc(1, sizeof(USR_ACCOUNT));
    while (fscanf(fp2, "%s\t%s\t%d\n", temp->usr_name, temp->usr_pwd, &temp->usr_role) == 3) {
        pUSR_ACCOUNT ACOUNT_TEMP = (pUSR_ACCOUNT)calloc(1, sizeof(USR_ACCOUNT));
        strcpy(ACOUNT_TEMP->usr_name, temp->usr_name);
        strcpy(ACOUNT_TEMP->usr_pwd, temp->usr_pwd);
        ACOUNT_TEMP->usr_role = temp->usr_role;
        if (NULL == *pUsr_Acount) {
            *pUsr_Acount = ACOUNT_TEMP;
        }
        else {  //尾插
            pUSR_ACCOUNT pUSR_ACOUNT_pCur, pUSR_ACOUNT_pPre;
            pUSR_ACOUNT_pCur = pUSR_ACOUNT_pPre = *pUsr_Acount;
            while (pUSR_ACOUNT_pCur) {
                pUSR_ACOUNT_pPre = pUSR_ACOUNT_pCur;
                pUSR_ACOUNT_pCur = pUSR_ACOUNT_pCur->pNext_Usr_Account;
            }
            pUSR_ACOUNT_pPre->pNext_Usr_Account = ACOUNT_TEMP;
            ACOUNT_TEMP->pNext_Usr_Account = pUSR_ACOUNT_pCur;
        }
    }
    fclose(fp2);


    fp2 = fopen(usr_infor_file_loc, "r");
    pUSR_INFOR tmp = (pUSR_INFOR)calloc(1, sizeof(USR_INFOR));
    while (fscanf(fp2, "%d\t%s\t%d\t%f\n", &tmp->usr_id, tmp->usr_name, &tmp->usr_course_id, &tmp->usr_course_score) == 4) {
        pUSR_INFOR INFOR_TEMP = (pUSR_INFOR)calloc(1, sizeof(USR_INFOR));
        INFOR_TEMP->usr_id = tmp->usr_id;
        strcpy(INFOR_TEMP->usr_name, tmp->usr_name);
        INFOR_TEMP->usr_course_id = tmp->usr_course_id;
        INFOR_TEMP->usr_course_score = tmp->usr_course_score;
        if (NULL == *pUsr_Infor) {
            *pUsr_Infor = INFOR_TEMP;
        }
        else { //尾插
            pUSR_INFOR pUSR_INFOR_pCur, pUSR_INFOR_pPre;
            pUSR_INFOR_pCur = pUSR_INFOR_pPre = *pUsr_Infor;
            while (pUSR_INFOR_pCur) {
                pUSR_INFOR_pPre = pUSR_INFOR_pCur;
                pUSR_INFOR_pCur = pUSR_INFOR_pCur->pNext_Usr_Infor;
            }
            pUSR_INFOR_pPre->pNext_Usr_Infor = INFOR_TEMP;
            INFOR_TEMP->pNext_Usr_Infor = pUSR_INFOR_pCur;
        }
    }
}

USR_ROLE role_confirm(pUSR_ACCOUNT pUsr_Account)
{
    system("cls");
    printf("enter usr_name:\n");
    char usr_name[USR_NAME_LEN];
    scanf("%s", usr_name);
    char usr_pwd[USR_PWD_LEN], c;
    int num = 0;
    printf("enter usr_password:\n");
    while (1) {
        c = getch();
        if (c == '\r') break;
        if (c == '\b') {
            if (num == 0) continue;
            else {
                printf("\b \b");
                num--;
            }
        }
        else {
            printf("*");
            usr_pwd[num++] = c;
        }
    }
    usr_pwd[num] = '\0';
    printf("\n");
    while (pUsr_Account) {
        if (strcmp(pUsr_Account->usr_name, usr_name) == 0) {
            if (strcmp(pUsr_Account->usr_pwd, usr_pwd) == 0) {
                //進入菜單
                return pUsr_Account->usr_role;
                break;
            }
            else {
                printf("password not correct!\n");
                return -1;
            }
        }
        pUsr_Account = pUsr_Account->pNext_Usr_Account;
    }
    if (NULL == pUsr_Account) {
        printf("The account doesn't exist!\n");
        return -1;
    }
}

SYSTEM_MENU_TYPE show_system_menu(USR_ROLE role)
{
    SYSTEM_MENU_TYPE num;
    system("cls");
    printf("*********************************************************************************************\n"
        "*******************Student Information Management  System***********************\n"
        "*********************************************************************************************\n\n");
    if (role == 1) {
        printf("\t\t\t\t1.search student information\n");
        printf("\t\t\t\t2.add student information\n");
        printf("\t\t\t\t3.update student information\n");
        printf("\t\t\t\t4.delete student information\n");
        printf("\t\t\t\t5.add user account\n");
        printf("\t\t\t\t6.update user account\n");
        printf("\t\t\t\t7.delete user account\n");
        printf("\t\t\t\t8.search user account\n");
        printf("\t\t\t\t9.exit\n");
    }
    else if (role == 2) {
        printf("\t\t\t\t1.search student information\n");
        printf("\t\t\t\t9.exit\n");
    }
    printf("*********************************************************************************************\n");
    printf("select a number:");
    scanf("%d", &num);
    return num;
}

SYSTEM_MENU_TYPE show_search_menu(USR_ROLE role)
{
    system("cls");
    SYSTEM_MENU_TYPE num;
    if (role == 1) {
        printf("0.search all\n");
    }
    printf("1.search by name\n");
    printf("2.search by id\n");
    printf("3.return\n");
    printf("select a number:");
    scanf("%d", &num);
    return num;
}

void search_usr_infor_all(pUSR_INFOR pUsr_Infor_List)
{
    if (NULL == pUsr_Infor_List) {
        printf("the information is empty!\n");
        return;
    }
    while (pUsr_Infor_List) {
        printf("%-5d %10s %-2d %.2f\n", pUsr_Infor_List->usr_id, pUsr_Infor_List->usr_name, pUsr_Infor_List->usr_course_id, pUsr_Infor_List->usr_course_score);
        pUsr_Infor_List = pUsr_Infor_List->pNext_Usr_Infor;
    }
}

void search_usr_infor_by_id(pUSR_INFOR pUsr_Infor_List, SEARCH_ID search_id)
{
    while (pUsr_Infor_List) {
        if (pUsr_Infor_List->usr_id == search_id) {
            printf("%-5d %10s %-2d %.2f\n", pUsr_Infor_List->usr_id, pUsr_Infor_List->usr_name, pUsr_Infor_List->usr_course_id, pUsr_Infor_List->usr_course_score);
            return;
        }
        pUsr_Infor_List = pUsr_Infor_List->pNext_Usr_Infor;
    }
    if (NULL == pUsr_Infor_List) {
        printf("the id doesn't exist!\n");
    }
}

void search_usr_infor_by_name(pUSR_INFOR pUsr_Infor_List, char * search_name)
{
    while (pUsr_Infor_List) {
        if (strcmp(pUsr_Infor_List->usr_name, search_name) == 0) {
            printf("%-5d %10s %-2d %.2f\n", pUsr_Infor_List->usr_id, pUsr_Infor_List->usr_name, pUsr_Infor_List->usr_course_id, pUsr_Infor_List->usr_course_score);
            return;
        }
        pUsr_Infor_List = pUsr_Infor_List->pNext_Usr_Infor;
    }
    if (NULL == pUsr_Infor_List) {
        printf("the name doesn't exist!\n");
    }
}

pUSR_INFOR add_usr_infor(pUSR_INFOR * ppUsr_Infor_List)
{
    printf("\nplease input the student information you want to add:\n");
    printf("Format:stu_id name score_id score\n");
    pUSR_INFOR temp = (pUSR_INFOR)calloc(1, sizeof(USR_INFOR));
    scanf("%d %s %d %f", &temp->usr_id, temp->usr_name, &temp->usr_course_id, &temp->usr_course_score);
    pUSR_INFOR pCur, pPre;
    pCur = pPre = *ppUsr_Infor_List;
    if (NULL == *ppUsr_Infor_List) {
        (*ppUsr_Infor_List) = temp;
    }
    else {
        while (pCur) {
            if (pCur->usr_id > temp->usr_id) {
                pPre->pNext_Usr_Infor = temp;
                temp->pNext_Usr_Infor = pCur;
                break;
            }
            pPre = pCur;
            pCur = pCur->pNext_Usr_Infor;
        }
        //尾插
        pPre->pNext_Usr_Infor = temp;
        temp->pNext_Usr_Infor = pCur;
    }
    printf("Added successfully!\n");
    return temp;
}

pUSR_INFOR update_usr_infor(pUSR_INFOR * pUsr_Infor_List, SEARCH_ID search_id)
{
    printf("\nplease input the student information you want to modify:\n");
    printf("Format:Name score_id score\n");
    char name[USR_NAME_LEN];
    int scoreid;
    float score;
    scanf("%s %d %f", name, &scoreid, &score);
    pUSR_INFOR pCur = *pUsr_Infor_List;
    while (pCur) {
        if (pCur->usr_id == search_id) {
            strcpy(pCur->usr_name, name);
            pCur->usr_course_id = scoreid;
            pCur->usr_course_score = score;
            printf("Modified successfully!\n");
            break;
        }
        pCur = pCur->pNext_Usr_Infor;
    }
    if (pCur == NULL) printf("Modify failed!\n");
    return pCur;
}

pUSR_INFOR delete_usr_infor(pUSR_INFOR * ppUsr_Infor_List, SEARCH_ID search_id)
{
    pUSR_INFOR pPre, pCur, pFree;
    pPre = pCur = *ppUsr_Infor_List;
    if (pCur->usr_id == search_id) {
        *ppUsr_Infor_List = pCur->pNext_Usr_Infor;
        return pCur;
    }
    while (pCur) {
        if (pCur->usr_id == search_id) {
            pFree = pCur;
            pCur = pCur->pNext_Usr_Infor;
            pPre->pNext_Usr_Infor = pCur;
            free(pFree);
            printf("Deleted successfully!\n");
            return pCur;
        }
        pPre = pCur;
        pCur = pCur->pNext_Usr_Infor;
    }
    if (pCur == NULL) {
        printf("Failed! No such id!\n");
        return NULL;
    }
}

void search_usr_account(pUSR_ACCOUNT pUsr_Account_List, char * search_name)
{
    while (pUsr_Account_List) {
        if (strcmp(pUsr_Account_List->usr_name, search_name) == 0) {
            printf("%s %s %d\n", pUsr_Account_List->usr_name, pUsr_Account_List->usr_pwd, pUsr_Account_List->usr_role);
            break;
        }
        pUsr_Account_List = pUsr_Account_List->pNext_Usr_Account;
    }
    if (NULL == pUsr_Account_List) {
        printf("No such name!\n");
    }
}

pUSR_ACCOUNT add_usr_account(pUSR_ACCOUNT * ppUsr_Account_List)
{
    printf("please input the account you want to add:\n");
    printf("ex:zhangsan 123 2\n");
    pUSR_ACCOUNT temp = (pUSR_ACCOUNT)calloc(1, sizeof(USR_ACCOUNT));
    scanf("%s %s %d", temp->usr_name, temp->usr_pwd, &temp->usr_role);
    pUSR_ACCOUNT pCur, pPre;
    pCur = pPre = *ppUsr_Account_List;
    if (NULL == *ppUsr_Account_List) {
        (*ppUsr_Account_List) = temp;
    }
    else {//尾插,先找尾結點
        while (pCur) {
            pPre = pCur;
            pCur = pCur->pNext_Usr_Account;
        }
        pPre->pNext_Usr_Account = temp;
        temp->pNext_Usr_Account = pCur;
    }
    printf("Added successfully!");
    return temp;
}

pUSR_ACCOUNT update_usr_account(pUSR_ACCOUNT * pUsr_Account_List, char * search_name)
{
    printf("\nplease input the account you want to modify:\n");
    printf("Format:name password role\n");
    char name[USR_NAME_LEN];
    char pwd[USR_NAME_LEN];
    int role;
    scanf("%s %s %d", name, pwd, &role);
    pUSR_ACCOUNT pCur;
    pCur = *pUsr_Account_List;
    while (pCur) {
        if (strcmp(pCur->usr_name, search_name) == 0) {
            pCur->usr_role = role;
            strcpy(pCur->usr_pwd, pwd);
            printf("Update successfully!\n");
            break;
        }
        pCur = pCur->pNext_Usr_Account;
    }
    if (NULL == pCur) {
        printf("No such name\n");
    }
    return pCur;
}

pUSR_ACCOUNT delete_usr_account(pUSR_ACCOUNT * ppUsr_Account_List, char * search_name)
{
    pUSR_ACCOUNT pPre, pCur, pFree;
    pPre = pCur = *ppUsr_Account_List;
    if (NULL == pCur) {
        *ppUsr_Account_List = pCur->pNext_Usr_Account;
    }
    else if (strcmp(pCur->usr_name, search_name) == 0)//刪除的是頭部
    {
        *ppUsr_Account_List = pCur->pNext_Usr_Account;
        pCur = pCur->pNext_Usr_Account;
        printf("delete successfully!\n");
        return pCur;
    }
    while (pCur) {
        if (strcmp(pCur->usr_name, search_name) == 0) {
            pFree = pCur;
            pCur = pCur->pNext_Usr_Account;
            pPre->pNext_Usr_Account = pCur;
            free(pFree);
            printf("delete successfully!\n");
            return pCur;
        }
        pPre = pCur;
        pCur = pCur->pNext_Usr_Account;
    }
}

void save_data_to_file(char * config_file_name, pUSR_ACCOUNT pUsr_Account_List, pUSR_INFOR pUsr_Infor_List)
{
    FILE *fp;
    fp = fopen(config_file_name, "r");
    if (NULL == fp) {
        perror("fopen");
        return;
    }
    char buf[FILENAME_MAX];
    memset(buf, 0, sizeof(buf));
    fread(buf, sizeof(char), sizeof(buf) - 1, fp);
    char * usr_account_file_loc = (char*)calloc(FILENAME_MAX, sizeof(char));
    strcpy(usr_account_file_loc, buf);

    memset(buf, 0, sizeof(buf));
    fread(buf, sizeof(char), sizeof(buf) - 1, fp);
    char * usr_infor_file_loc = (char*)calloc(FILENAME_MAX, sizeof(char));
    strcpy(usr_infor_file_loc, buf);

    fclose(fp);

    FILE *fp2;

    fp2 = fopen("usr_account.txt", "w+");
    if (NULL == fp2) {
        perror("fopen");
        return;
    }
    while (pUsr_Account_List) {
        fprintf(fp, "%s %s %d\n", pUsr_Account_List->usr_name, pUsr_Account_List->usr_pwd, pUsr_Account_List->usr_role);
        pUsr_Account_List = pUsr_Account_List->pNext_Usr_Account;
    }
    fclose(fp2);

    fp2 = fopen("usr_infor.txt", "w+");
    if (NULL == fp2) {
        perror("fopen");
        return;
    }
    while (pUsr_Infor_List) {
        fprintf(fp, "%d %s %d %.2f\n", pUsr_Infor_List->usr_id, pUsr_Infor_List->usr_name, pUsr_Infor_List->usr_course_id, pUsr_Infor_List->usr_course_score);
        pUsr_Infor_List = pUsr_Infor_List->pNext_Usr_Infor;
    }

    fclose(fp2);
}

main.c

#include"SIMS.h"

int main() {
    pUSR_ACCOUNT pUSR_ACCOUNT_head = NULL;
    pUSR_INFOR pUSR_INFOR_head = NULL;
    USR_INFOR_NUM usr_infor_num = 0;
    SYSTEM_MENU_TYPE role, num, id, search_menu_num;
    int search_id;
    char temp_Name[USR_NAME_LEN];
    char search_id_name[USR_NAME_LEN];
    system_init("configure.txt", &pUSR_ACCOUNT_head, &pUSR_INFOR_head);
//登錄界面
label1:
    role = role_confirm(pUSR_ACCOUNT_head);
    if (role == -1) {
        system("pause");
        goto label1;
    }
//主界面
label2:
    num = show_system_menu(role);
    if (role == 1) {
        switch (num)
        {
        case 1:
            search_menu_num = show_search_menu(role);
            switch (search_menu_num) {
                case 0:
                    search_usr_infor_all(pUSR_INFOR_head);
                    system("pause");
                    goto label2;
                    break;
                case 1:
                    printf("please input the name of student you want to search:\n");
                    memset(search_id_name, 0, sizeof(search_id_name));
                    scanf("%s", search_id_name);
                    search_usr_infor_by_name(pUSR_INFOR_head, search_id_name);
                    system("pause");
                    goto label2;
                    break;
                case 2:
                    printf("please input the id of student you want to search:\n");
                    scanf("%d", &search_id);
                    search_usr_infor_by_id(pUSR_INFOR_head, search_id);
                    system("pause");
                    goto label2;
                    break;
                case 3:
                    goto label2;
                    break;
            }
            break;
        case 2:
            add_usr_infor(&pUSR_INFOR_head);
            system("pause");
            goto label2;
            break;
        case 3:
            printf("please input the id you want to modify:\n");
            scanf("%d", &id);
            update_usr_infor(&pUSR_INFOR_head, id);
            system("pause");
            goto label2;
            break;
        case 4:
            if (NULL == pUSR_INFOR_head) {
                printf("the list is empty!\n");
                system("pause");
                goto label2;
                break;
            }
            printf("please input the id you want to delete:\n");
            scanf("%d", &id);
            delete_usr_infor(&pUSR_INFOR_head, id);
            system("pause");
            goto label2;
            break;
        case 5:
            add_usr_account(&pUSR_ACCOUNT_head);
            system("pause");
            goto label2;
            break;
        case 6:
            printf("please input the name of account you want to modify:\n");
            memset(temp_Name, 0, sizeof(temp_Name));
            scanf("%s", temp_Name);
            update_usr_account(&pUSR_ACCOUNT_head, temp_Name);
            system("pause");
            goto label2;
            break;
        case 7:
            if (NULL == pUSR_ACCOUNT_head) {
                printf("the list is empty!\n");
                system("pause");
                goto label2;
                break;
            }
            printf("please input the name of account you want to delete:\n");
            memset(temp_Name, 0, sizeof(temp_Name));
            scanf("%s", temp_Name);
            delete_usr_account(&pUSR_ACCOUNT_head, temp_Name);
            system("pause");
            goto label2;
            break;
        case 8:
            printf("please input the name of account you want to search:\n");
            memset(temp_Name, 0, sizeof(temp_Name));
            scanf("%s", temp_Name);
            search_usr_account(pUSR_ACCOUNT_head, temp_Name);
            system("pause");
            goto label2;
            break;
        case 9:
            save_data_to_file("configure.txt", pUSR_ACCOUNT_head, pUSR_INFOR_head);
            system("pause");
            break;
        default:
            printf("Input error!\n");
            system("pause");
            goto label2;
            break;
        }
    }
    else {
        switch (num)
        {
        case 1:
            show_search_menu(role);
            goto label2;
            break;
        case 9:
            save_data_to_file("configure.txt", pUSR_ACCOUNT_head, pUSR_INFOR_head);
            break;
        default:
            printf("Input error!\n");
            system("pause");
            goto label2;
            break;
        }
        return 0;
    }
}

C語言強化——學生管理系統